projects
/
git.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
contrib/git-svn.txt: add a note about renamed/copied directory support
[git.git]
/
rev-parse.c
diff --git
a/rev-parse.c
b/rev-parse.c
index
3c99a79
..
a5fb93c
100644
(file)
--- a/
rev-parse.c
+++ b/
rev-parse.c
@@
-48,11
+48,16
@@
static int is_rev_argument(const char *arg)
"--show-breaks",
"--sparse",
"--topo-order",
"--show-breaks",
"--sparse",
"--topo-order",
+ "--date-order",
"--unpacked",
NULL
};
const char **p = rev_args;
"--unpacked",
NULL
};
const char **p = rev_args;
+ /* accept -<digit>, like traditional "head" */
+ if ((*arg == '-') && isdigit(arg[1]))
+ return 1;
+
for (;;) {
const char *str = *p++;
int len;
for (;;) {
const char *str = *p++;
int len;
@@
-103,12
+108,15
@@
static void show_rev(int type, const unsigned char *sha1, const char *name)
}
/* Output a flag, only if filter allows it. */
}
/* Output a flag, only if filter allows it. */
-static
void
show_flag(char *arg)
+static
int
show_flag(char *arg)
{
if (!(filter & DO_FLAGS))
{
if (!(filter & DO_FLAGS))
- return;
- if (filter & (is_rev_argument(arg) ? DO_REVS : DO_NOREV))
+ return
0
;
+ if (filter & (is_rev_argument(arg) ? DO_REVS : DO_NOREV))
{
show(arg);
show(arg);
+ return 1;
+ }
+ return 0;
}
static void show_default(void)
}
static void show_default(void)
@@
-143,11
+151,14
@@
static void show_datestring(const char *flag, const char *datestr)
show(buffer);
}
show(buffer);
}
-static
void
show_file(const char *arg)
+static
int
show_file(const char *arg)
{
show_default();
{
show_default();
- if ((filter & (DO_NONFLAGS|DO_NOREV)) == (DO_NONFLAGS|DO_NOREV))
+ if ((filter & (DO_NONFLAGS|DO_NOREV)) == (DO_NONFLAGS|DO_NOREV))
{
show(arg);
show(arg);
+ return 1;
+ }
+ return 0;
}
int main(int argc, char **argv)
}
int main(int argc, char **argv)
@@
-215,12
+226,12
@@
int main(int argc, char **argv)
continue;
}
if (!strcmp(arg, "--short") ||
continue;
}
if (!strcmp(arg, "--short") ||
- !strncmp(arg, "--short=",
9
)) {
+ !strncmp(arg, "--short=",
8
)) {
filter &= ~(DO_FLAGS|DO_NOREV);
verify = 1;
abbrev = DEFAULT_ABBREV;
filter &= ~(DO_FLAGS|DO_NOREV);
verify = 1;
abbrev = DEFAULT_ABBREV;
- if (arg[
8
] == '=')
- abbrev = strtoul(arg +
9
, NULL, 10);
+ if (arg[
7
] == '=')
+ abbrev = strtoul(arg +
8
, NULL, 10);
if (abbrev < MINIMUM_ABBREV)
abbrev = MINIMUM_ABBREV;
else if (40 <= abbrev)
if (abbrev < MINIMUM_ABBREV)
abbrev = MINIMUM_ABBREV;
else if (40 <= abbrev)
@@
-292,9
+303,8
@@
int main(int argc, char **argv)
show_datestring("--min-age=", arg+8);
continue;
}
show_datestring("--min-age=", arg+8);
continue;
}
- if (verify)
+ if (
show_flag(arg) &&
verify)
die("Needed a single revision");
die("Needed a single revision");
- show_flag(arg);
continue;
}
continue;
}
@@
-323,14
+333,13
@@
int main(int argc, char **argv)
show_rev(REVERSED, sha1, arg+1);
continue;
}
show_rev(REVERSED, sha1, arg+1);
continue;
}
+ as_is = 1;
+ if (!show_file(arg))
+ continue;
if (verify)
die("Needed a single revision");
if (verify)
die("Needed a single revision");
- if ((filter & DO_REVS) &&
- (filter & DO_NONFLAGS) && /* !def && */
- lstat(arg, &st) < 0)
+ if (lstat(arg, &st) < 0)
die("'%s': %s", arg, strerror(errno));
die("'%s': %s", arg, strerror(errno));
- as_is = 1;
- show_file(arg);
}
show_default();
if (verify && revs_count != 1)
}
show_default();
if (verify && revs_count != 1)