diff options
author | Junio C Hamano <junkio@cox.net> | 2007-02-26 01:20:42 -0800 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2007-02-26 01:20:42 -0800 |
commit | 048f48a2fdefdf71e7af19ec7111000ce2ebf52e (patch) | |
tree | ee91b56c9071972b1585fa65838da5748c0abfd9 /builtin-name-rev.c | |
parent | 646b3299613f0dd947557bc965660986d024322b (diff) | |
parent | c260d790c85c07a5f50235f664c36725deedfb10 (diff) | |
download | git-048f48a2fdefdf71e7af19ec7111000ce2ebf52e.tar.gz |
Merge branch 'master' into js/diff-ni
* master: (201 commits)
Documentation: link in 1.5.0.2 material to the top documentation page.
Documentation: document remote.<name>.tagopt
GIT 1.5.0.2
git-remote: support remotes with a dot in the name
Documentation: describe "-f/-t/-m" options to "git-remote add"
diff --cc: fix display of symlink conflicts during a merge.
merge-recursive: fix longstanding bug in merging symlinks
merge-index: fix longstanding bug in merging symlinks
diff --cached: give more sensible error message when HEAD is yet to be created.
Update tests to use test-chmtime
Add test-chmtime: a utility to change mtime on files
Add Release Notes to prepare for 1.5.0.2
Allow arbitrary number of arguments to git-pack-objects
rerere: do not deal with symlinks.
rerere: do not skip two conflicted paths next to each other.
Don't modify CREDITS-FILE if it hasn't changed.
diff-patch: Avoid emitting double-slashes in textual patch.
Reword git-am 3-way fallback failure message.
Limit filename for format-patch
core.legacyheaders: Use the description used in RelNotes-1.5.0
...
Diffstat (limited to 'builtin-name-rev.c')
-rw-r--r-- | builtin-name-rev.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/builtin-name-rev.c b/builtin-name-rev.c index 36f1ba6d38..c022224361 100644 --- a/builtin-name-rev.c +++ b/builtin-name-rev.c @@ -57,13 +57,17 @@ copy_data: parents; parents = parents->next, parent_number++) { if (parent_number > 1) { - char *new_name = xmalloc(strlen(tip_name)+8); + int len = strlen(tip_name); + char *new_name = xmalloc(len + 8); + if (len > 2 && !strcmp(tip_name + len - 2, "^0")) + len -= 2; if (generation > 0) - sprintf(new_name, "%s~%d^%d", tip_name, + sprintf(new_name, "%.*s~%d^%d", len, tip_name, generation, parent_number); else - sprintf(new_name, "%s^%d", tip_name, parent_number); + sprintf(new_name, "%.*s^%d", len, tip_name, + parent_number); name_rev(parents->item, new_name, merge_traversals + 1 , 0, 0); @@ -85,7 +89,7 @@ static int name_ref(const char *path, const unsigned char *sha1, int flags, void struct name_ref_data *data = cb_data; int deref = 0; - if (data->tags_only && strncmp(path, "refs/tags/", 10)) + if (data->tags_only && prefixcmp(path, "refs/tags/")) return 0; if (data->ref_filter && fnmatch(data->ref_filter, path, 0)) @@ -101,9 +105,9 @@ static int name_ref(const char *path, const unsigned char *sha1, int flags, void if (o && o->type == OBJ_COMMIT) { struct commit *commit = (struct commit *)o; - if (!strncmp(path, "refs/heads/", 11)) + if (!prefixcmp(path, "refs/heads/")) path = path + 11; - else if (!strncmp(path, "refs/", 5)) + else if (!prefixcmp(path, "refs/")) path = path + 5; name_rev(commit, xstrdup(path), 0, 0, deref); @@ -127,10 +131,15 @@ static const char* get_rev_name(struct object *o) if (!n->generation) return n->tip_name; - - snprintf(buffer, sizeof(buffer), "%s~%d", n->tip_name, n->generation); - - return buffer; + else { + int len = strlen(n->tip_name); + if (len > 2 && !strcmp(n->tip_name + len - 2, "^0")) + len -= 2; + snprintf(buffer, sizeof(buffer), "%.*s~%d", len, n->tip_name, + n->generation); + + return buffer; + } } int cmd_name_rev(int argc, const char **argv, const char *prefix) @@ -156,7 +165,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) } else if (!strcmp(*argv, "--tags")) { data.tags_only = 1; continue; - } else if (!strncmp(*argv, "--refs=", 7)) { + } else if (!prefixcmp(*argv, "--refs=")) { data.ref_filter = *argv + 7; continue; } else if (!strcmp(*argv, "--all")) { |