~ubuntu-branches/debian/sid/git/sid

« back to all changes in this revision

Viewing changes to builtin/rev-parse.c

  • Committer: Package Import Robot
  • Author(s): Jonathan Nieder
  • Date: 2013-06-12 07:50:53 UTC
  • mfrom: (1.2.19) (2.1.31 experimental)
  • Revision ID: package-import@ubuntu.com-20130612075053-uue9xe0dq0rvm44y
Tags: 1:1.8.3.1-1
* merge branch debian-experimental
* new upstream point release (see RelNotes/1.8.3.1.txt).
* debian/watch: use xz-compressed tarballs from kernel.org.

Show diffs side-by-side

added added

removed removed

Lines of Context:
195
195
        return 0;
196
196
}
197
197
 
 
198
static int show_abbrev(const unsigned char *sha1, void *cb_data)
 
199
{
 
200
        show_rev(NORMAL, sha1, NULL);
 
201
        return 0;
 
202
}
 
203
 
198
204
static void show_datestring(const char *flag, const char *datestr)
199
205
{
200
206
        static char buffer[100];
224
230
        const char *next;
225
231
        const char *this;
226
232
        int symmetric;
 
233
        static const char head_by_default[] = "HEAD";
227
234
 
228
235
        if (!(dotdot = strstr(arg, "..")))
229
236
                return 0;
235
242
        next += symmetric;
236
243
 
237
244
        if (!*next)
238
 
                next = "HEAD";
 
245
                next = head_by_default;
239
246
        if (dotdot == arg)
240
 
                this = "HEAD";
241
 
        if (!get_sha1(this, sha1) && !get_sha1(next, end)) {
 
247
                this = head_by_default;
 
248
 
 
249
        if (this == head_by_default && next == head_by_default &&
 
250
            !symmetric) {
 
251
                /*
 
252
                 * Just ".."?  That is not a range but the
 
253
                 * pathspec for the parent directory.
 
254
                 */
 
255
                *dotdot = '.';
 
256
                return 0;
 
257
        }
 
258
 
 
259
        if (!get_sha1_committish(this, sha1) && !get_sha1_committish(next, end)) {
242
260
                show_rev(NORMAL, end, next);
243
261
                show_rev(symmetric ? NORMAL : REVERSED, sha1, this);
244
262
                if (symmetric) {
278
296
                return 0;
279
297
 
280
298
        *dotdot = 0;
281
 
        if (get_sha1(arg, sha1))
 
299
        if (get_sha1_committish(arg, sha1))
282
300
                return 0;
283
301
 
284
302
        if (!parents_only)
318
336
{
319
337
        static int keep_dashdash = 0, stop_at_non_option = 0;
320
338
        static char const * const parseopt_usage[] = {
321
 
                "git rev-parse --parseopt [options] -- [<args>...]",
 
339
                N_("git rev-parse --parseopt [options] -- [<args>...]"),
322
340
                NULL
323
341
        };
324
342
        static struct option parseopt_opts[] = {
325
343
                OPT_BOOLEAN(0, "keep-dashdash", &keep_dashdash,
326
 
                                        "keep the `--` passed as an arg"),
 
344
                                        N_("keep the `--` passed as an arg")),
327
345
                OPT_BOOLEAN(0, "stop-at-non-option", &stop_at_non_option,
328
 
                                        "stop parsing after the "
329
 
                                        "first non-option argument"),
 
346
                                        N_("stop parsing after the "
 
347
                                           "first non-option argument")),
330
348
                OPT_END(),
331
349
        };
332
350
 
443
461
}
444
462
 
445
463
static const char builtin_rev_parse_usage[] =
446
 
"git rev-parse --parseopt [options] -- [<args>...]\n"
447
 
"   or: git rev-parse --sq-quote [<arg>...]\n"
448
 
"   or: git rev-parse [options] [<arg>...]\n"
449
 
"\n"
450
 
"Run \"git rev-parse --parseopt -h\" for more information on the first usage.";
 
464
N_("git rev-parse --parseopt [options] -- [<args>...]\n"
 
465
   "   or: git rev-parse --sq-quote [<arg>...]\n"
 
466
   "   or: git rev-parse [options] [<arg>...]\n"
 
467
   "\n"
 
468
   "Run \"git rev-parse --parseopt -h\" for more information on the first usage.");
451
469
 
452
470
int cmd_rev_parse(int argc, const char **argv, const char *prefix)
453
471
{
486
504
 
487
505
                if (as_is) {
488
506
                        if (show_file(arg) && as_is < 2)
489
 
                                verify_filename(prefix, arg);
 
507
                                verify_filename(prefix, arg, 0);
490
508
                        continue;
491
509
                }
492
510
                if (!strcmp(arg,"-n")) {
589
607
                                for_each_ref(show_reference, NULL);
590
608
                                continue;
591
609
                        }
 
610
                        if (!prefixcmp(arg, "--disambiguate=")) {
 
611
                                for_each_abbrev(arg + 15, show_abbrev, NULL);
 
612
                                continue;
 
613
                        }
592
614
                        if (!strcmp(arg, "--bisect")) {
593
615
                                for_each_ref_in("refs/bisect/bad", show_reference, NULL);
594
616
                                for_each_ref_in("refs/bisect/good", anti_reference, NULL);
734
756
                as_is = 1;
735
757
                if (!show_file(arg))
736
758
                        continue;
737
 
                verify_filename(prefix, arg);
 
759
                verify_filename(prefix, arg, 1);
738
760
        }
739
761
        if (verify) {
740
762
                if (revs_count == 1) {