From 473f4c96e315478185c4a07d6e7fb65801ee40b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Sun, 6 Nov 2011 13:06:22 +0100 Subject: apply: get rid of useless x < 0 comparison on a size_t type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit According to the C standard size_t is always unsigned, therefore the comparison "n1 < 0 || n2 < 0" when n1 and n2 are size_t will always be false. This was raised by clang 2.9 which throws this warning when compiling apply.c: builtin/apply.c:253:9: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare] if (n1 < 0 || n2 < 0) ~~ ^ ~ builtin/apply.c:253:19: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare] if (n1 < 0 || n2 < 0) ~~ ^ ~ This check was originally added in v1.6.5-rc0~53^2 by Giuseppe Bilotta while adding an option to git-apply to ignore whitespace differences. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano diff --git a/builtin/apply.c b/builtin/apply.c index f2edc52..d600ac6 100644 --- a/builtin/apply.c +++ b/builtin/apply.c @@ -250,9 +250,6 @@ static int fuzzy_matchlines(const char *s1, size_t n1, const char *last2 = s2 + n2 - 1; int result = 0; - if (n1 < 0 || n2 < 0) - return 0; - /* ignore line endings */ while ((*last1 == '\r') || (*last1 == '\n')) last1--; -- cgit v0.10.2-6-g49f6 From 83838d5c1b8ca2efee52184136776c3cf7d5df2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Sun, 6 Nov 2011 13:06:23 +0100 Subject: cast variable in call to free() in builtin/diff.c and submodule.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both of these free() calls are freeing a "const unsigned char (*)[20]" type while free() expects a "void *". This results in the following warning under clang 2.9: builtin/diff.c:185:7: warning: passing 'const unsigned char (*)[20]' to parameter of type 'void *' discards qualifiers free(parent); ^~~~~~ submodule.c:394:7: warning: passing 'const unsigned char (*)[20]' to parameter of type 'void *' discards qualifiers free(parents); ^~~~~~~ This free()-ing without a cast was added by Jim Meyering to builtin/diff.c in v1.7.6-rc3~4 and later by Fredrik Gustafsson in submodule.c in v1.7.7-rc1~25^2. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano diff --git a/builtin/diff.c b/builtin/diff.c index 1118689..0fe638f 100644 --- a/builtin/diff.c +++ b/builtin/diff.c @@ -182,7 +182,7 @@ static int builtin_diff_combined(struct rev_info *revs, hashcpy((unsigned char *)(parent + i), ent[i].item->sha1); diff_tree_combined(parent[0], parent + 1, ents - 1, revs->dense_combined_merges, revs); - free(parent); + free((void *)parent); return 0; } diff --git a/submodule.c b/submodule.c index ad86534..09181ff 100644 --- a/submodule.c +++ b/submodule.c @@ -385,7 +385,7 @@ static void commit_need_pushing(struct commit *commit, struct commit_list *paren rev.diffopt.format_callback_data = needs_pushing; diff_tree_combined(commit->object.sha1, parents, n, 1, &rev); - free(parents); + free((void *)parents); } int check_submodule_needs_pushing(unsigned char new_sha1[20], const char *remotes_name) -- cgit v0.10.2-6-g49f6 From fc001b526c42e5fb776340136a2fb247e391a61b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Sun, 27 Nov 2011 17:15:32 +0700 Subject: checkout,merge: loosen overwriting untracked file check based on info/exclude MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Back in 1127148 (Loosen "working file will be lost" check in Porcelain-ish - 2006-12-04), git-checkout.sh learned to quietly overwrite ignored files. Howver the code only took .gitignore files into account. Standard ignored files include all specified in .gitignore files in working directory _and_ $GIT_DIR/info/exclude. This patch makes sure ignored files in info/exclude can also be overwritten automatically in the spirit of the original patch. Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano diff --git a/builtin/checkout.c b/builtin/checkout.c index 560eae1..2b90e6b 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -401,7 +401,7 @@ static int merge_working_tree(struct checkout_opts *opts, topts.fn = twoway_merge; topts.dir = xcalloc(1, sizeof(*topts.dir)); topts.dir->flags |= DIR_SHOW_IGNORED; - topts.dir->exclude_per_dir = ".gitignore"; + setup_standard_excludes(topts.dir); tree = parse_tree_indirect(old->commit ? old->commit->object.sha1 : (unsigned char *)EMPTY_TREE_SHA1_BIN); diff --git a/builtin/merge.c b/builtin/merge.c index 5f65c0c..29c4397 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -708,7 +708,7 @@ int checkout_fast_forward(const unsigned char *head, const unsigned char *remote memset(&t, 0, sizeof(t)); memset(&dir, 0, sizeof(dir)); dir.flags |= DIR_SHOW_IGNORED; - dir.exclude_per_dir = ".gitignore"; + setup_standard_excludes(&dir); opts.dir = &dir; opts.head_idx = 1; -- cgit v0.10.2-6-g49f6 From 5914f2d057c259668695bccab8e9bec3a4bead53 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 8 Dec 2011 03:43:19 -0500 Subject: fetch: create status table using strbuf When we fetch from a remote, we print a status table like: From url * [new branch] foo -> origin/foo We create this table in a static buffer using sprintf. If the remote refnames are long, they can overflow this buffer and smash the stack. Instead, let's use a strbuf to build the string. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano diff --git a/builtin/fetch.c b/builtin/fetch.c index 93c9938..4f4af2a 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -239,23 +239,23 @@ static int s_update_ref(const char *action, static int update_local_ref(struct ref *ref, const char *remote, - char *display) + struct strbuf *display) { struct commit *current = NULL, *updated; enum object_type type; struct branch *current_branch = branch_get(NULL); const char *pretty_ref = prettify_refname(ref->name); - *display = 0; type = sha1_object_info(ref->new_sha1, NULL); if (type < 0) die(_("object %s not found"), sha1_to_hex(ref->new_sha1)); if (!hashcmp(ref->old_sha1, ref->new_sha1)) { if (verbosity > 0) - sprintf(display, "= %-*s %-*s -> %s", TRANSPORT_SUMMARY_WIDTH, - _("[up to date]"), REFCOL_WIDTH, remote, - pretty_ref); + strbuf_addf(display, "= %-*s %-*s -> %s", + TRANSPORT_SUMMARY_WIDTH, + _("[up to date]"), REFCOL_WIDTH, + remote, pretty_ref); return 0; } @@ -267,9 +267,10 @@ static int update_local_ref(struct ref *ref, * If this is the head, and it's not okay to update * the head, and the old value of the head isn't empty... */ - sprintf(display, _("! %-*s %-*s -> %s (can't fetch in current branch)"), - TRANSPORT_SUMMARY_WIDTH, _("[rejected]"), REFCOL_WIDTH, remote, - pretty_ref); + strbuf_addf(display, + _("! %-*s %-*s -> %s (can't fetch in current branch)"), + TRANSPORT_SUMMARY_WIDTH, _("[rejected]"), + REFCOL_WIDTH, remote, pretty_ref); return 1; } @@ -277,9 +278,11 @@ static int update_local_ref(struct ref *ref, !prefixcmp(ref->name, "refs/tags/")) { int r; r = s_update_ref("updating tag", ref, 0); - sprintf(display, "%c %-*s %-*s -> %s%s", r ? '!' : '-', - TRANSPORT_SUMMARY_WIDTH, _("[tag update]"), REFCOL_WIDTH, remote, - pretty_ref, r ? _(" (unable to update local ref)") : ""); + strbuf_addf(display, "%c %-*s %-*s -> %s%s", + r ? '!' : '-', + TRANSPORT_SUMMARY_WIDTH, _("[tag update]"), + REFCOL_WIDTH, remote, pretty_ref, + r ? _(" (unable to update local ref)") : ""); return r; } @@ -302,9 +305,11 @@ static int update_local_ref(struct ref *ref, } r = s_update_ref(msg, ref, 0); - sprintf(display, "%c %-*s %-*s -> %s%s", r ? '!' : '*', - TRANSPORT_SUMMARY_WIDTH, what, REFCOL_WIDTH, remote, pretty_ref, - r ? _(" (unable to update local ref)") : ""); + strbuf_addf(display, "%c %-*s %-*s -> %s%s", + r ? '!' : '*', + TRANSPORT_SUMMARY_WIDTH, what, + REFCOL_WIDTH, remote, pretty_ref, + r ? _(" (unable to update local ref)") : ""); return r; } @@ -318,9 +323,11 @@ static int update_local_ref(struct ref *ref, (recurse_submodules != RECURSE_SUBMODULES_ON)) check_for_new_submodule_commits(ref->new_sha1); r = s_update_ref("fast-forward", ref, 1); - sprintf(display, "%c %-*s %-*s -> %s%s", r ? '!' : ' ', - TRANSPORT_SUMMARY_WIDTH, quickref, REFCOL_WIDTH, remote, - pretty_ref, r ? _(" (unable to update local ref)") : ""); + strbuf_addf(display, "%c %-*s %-*s -> %s%s", + r ? '!' : ' ', + TRANSPORT_SUMMARY_WIDTH, quickref, + REFCOL_WIDTH, remote, pretty_ref, + r ? _(" (unable to update local ref)") : ""); return r; } else if (force || ref->force) { char quickref[84]; @@ -332,15 +339,17 @@ static int update_local_ref(struct ref *ref, (recurse_submodules != RECURSE_SUBMODULES_ON)) check_for_new_submodule_commits(ref->new_sha1); r = s_update_ref("forced-update", ref, 1); - sprintf(display, "%c %-*s %-*s -> %s (%s)", r ? '!' : '+', - TRANSPORT_SUMMARY_WIDTH, quickref, REFCOL_WIDTH, remote, - pretty_ref, - r ? _("unable to update local ref") : _("forced update")); + strbuf_addf(display, "%c %-*s %-*s -> %s (%s)", + r ? '!' : '+', + TRANSPORT_SUMMARY_WIDTH, quickref, + REFCOL_WIDTH, remote, pretty_ref, + r ? _("unable to update local ref") : _("forced update")); return r; } else { - sprintf(display, "! %-*s %-*s -> %s %s", - TRANSPORT_SUMMARY_WIDTH, _("[rejected]"), REFCOL_WIDTH, remote, - pretty_ref, _("(non-fast-forward)")); + strbuf_addf(display, "! %-*s %-*s -> %s %s", + TRANSPORT_SUMMARY_WIDTH, _("[rejected]"), + REFCOL_WIDTH, remote, pretty_ref, + _("(non-fast-forward)")); return 1; } } @@ -350,8 +359,8 @@ static int store_updated_refs(const char *raw_url, const char *remote_name, { FILE *fp; struct commit *commit; - int url_len, i, note_len, shown_url = 0, rc = 0; - char note[1024]; + int url_len, i, shown_url = 0, rc = 0; + struct strbuf note = STRBUF_INIT; const char *what, *kind; struct ref *rm; char *url, *filename = dry_run ? "/dev/null" : git_path("FETCH_HEAD"); @@ -407,19 +416,17 @@ static int store_updated_refs(const char *raw_url, const char *remote_name, if (4 < i && !strncmp(".git", url + i - 3, 4)) url_len = i - 3; - note_len = 0; + strbuf_reset(¬e); if (*what) { if (*kind) - note_len += sprintf(note + note_len, "%s ", - kind); - note_len += sprintf(note + note_len, "'%s' of ", what); + strbuf_addf(¬e, "%s ", kind); + strbuf_addf(¬e, "'%s' of ", what); } - note[note_len] = '\0'; fprintf(fp, "%s\t%s\t%s", sha1_to_hex(commit ? commit->object.sha1 : rm->old_sha1), rm->merge ? "" : "not-for-merge", - note); + note.buf); for (i = 0; i < url_len; ++i) if ('\n' == url[i]) fputs("\\n", fp); @@ -427,21 +434,24 @@ static int store_updated_refs(const char *raw_url, const char *remote_name, fputc(url[i], fp); fputc('\n', fp); + strbuf_reset(¬e); if (ref) { - rc |= update_local_ref(ref, what, note); + rc |= update_local_ref(ref, what, ¬e); free(ref); } else - sprintf(note, "* %-*s %-*s -> FETCH_HEAD", - TRANSPORT_SUMMARY_WIDTH, *kind ? kind : "branch", - REFCOL_WIDTH, *what ? what : "HEAD"); - if (*note) { + strbuf_addf(¬e, "* %-*s %-*s -> FETCH_HEAD", + TRANSPORT_SUMMARY_WIDTH, + *kind ? kind : "branch", + REFCOL_WIDTH, + *what ? what : "HEAD"); + if (note.len) { if (verbosity >= 0 && !shown_url) { fprintf(stderr, _("From %.*s\n"), url_len, url); shown_url = 1; } if (verbosity >= 0) - fprintf(stderr, " %s\n", note); + fprintf(stderr, " %s\n", note.buf); } } free(url); @@ -450,6 +460,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name, error(_("some local refs could not be updated; try running\n" " 'git remote prune %s' to remove any old, conflicting " "branches"), remote_name); + strbuf_release(¬e); return rc; } -- cgit v0.10.2-6-g49f6 From c3ea051544cb1d98a5ae7f64d077084a9a5db5c1 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 8 Dec 2011 05:25:54 -0500 Subject: blame: don't overflow time buffer When showing the raw timestamp, we format the numeric seconds-since-epoch into a buffer, followed by the timezone string. This string has come straight from the commit object. A well-formed object should have a timezone string of only a few bytes, but we could be operating on data pushed by a malicious user. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano diff --git a/builtin/blame.c b/builtin/blame.c index 26a5d42..3e1f7e1 100644 --- a/builtin/blame.c +++ b/builtin/blame.c @@ -1598,7 +1598,7 @@ static const char *format_time(unsigned long time, const char *tz_str, int tz; if (show_raw_time) { - sprintf(time_buf, "%lu %s", time, tz_str); + snprintf(time_buf, sizeof(time_buf), "%lu %s", time, tz_str); } else { tz = atoi(tz_str); -- cgit v0.10.2-6-g49f6 From 15b7898c5e9fc6fed9a6064213cfcd08cf7d7314 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 13 Dec 2011 21:30:40 -0800 Subject: Git 1.7.6.5 Signed-off-by: Junio C Hamano diff --git a/Documentation/RelNotes/1.7.6.5.txt b/Documentation/RelNotes/1.7.6.5.txt new file mode 100644 index 0000000..6713132 --- /dev/null +++ b/Documentation/RelNotes/1.7.6.5.txt @@ -0,0 +1,26 @@ +Git v1.7.6.5 Release Notes +========================== + +Fixes since v1.7.6.4 +-------------------- + + * The date parser did not accept timezone designators that lack minutes + part and also has a colon between "hh:mm". + + * After fetching from a remote that has very long refname, the reporting + output could have corrupted by overrunning a static buffer. + + * "git mergetool" did not use its arguments as pathspec, but as a path to + the file that may not even have any conflict. + + * "git name-rev --all" tried to name all _objects_, naturally failing to + describe many blobs and trees, instead of showing only commits as + advertised in its documentation. + + * "git remote rename $a $b" were not careful to match the remote name + against $a (i.e. source side of the remote nickname). + + * "gitweb" used to produce a non-working link while showing the contents + of a blob, when JavaScript actions are enabled. + +Also contains minor fixes and documentation updates. diff --git a/Documentation/git.txt b/Documentation/git.txt index d148135..bcedfc1 100644 --- a/Documentation/git.txt +++ b/Documentation/git.txt @@ -44,9 +44,10 @@ unreleased) version of git, that is available from 'master' branch of the `git.git` repository. Documentation for older releases are available here: -* link:v1.7.6.4/git.html[documentation for release 1.7.6.4] +* link:v1.7.6.5/git.html[documentation for release 1.7.6.5] * release notes for + link:RelNotes/1.7.6.5.txt[1.7.6.5], link:RelNotes/1.7.6.4.txt[1.7.6.4], link:RelNotes/1.7.6.3.txt[1.7.6.3], link:RelNotes/1.7.6.2.txt[1.7.6.2], diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN index b42c77c..0595495 100755 --- a/GIT-VERSION-GEN +++ b/GIT-VERSION-GEN @@ -1,7 +1,7 @@ #!/bin/sh GVF=GIT-VERSION-FILE -DEF_VER=v1.7.6.4 +DEF_VER=v1.7.6.5 LF=' ' diff --git a/RelNotes b/RelNotes index 2b3ea81..08cae90 120000 --- a/RelNotes +++ b/RelNotes @@ -1 +1 @@ -Documentation/RelNotes/1.7.6.4.txt \ No newline at end of file +Documentation/RelNotes/1.7.6.5.txt \ No newline at end of file -- cgit v0.10.2-6-g49f6 From 66c11f02b031aca6f1756086fefdf4b8a5575c56 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 13 Dec 2011 21:55:31 -0800 Subject: Git 1.7.7.5 Signed-off-by: Junio C Hamano diff --git a/Documentation/RelNotes/1.7.7.5.txt b/Documentation/RelNotes/1.7.7.5.txt new file mode 100644 index 0000000..7b09319 --- /dev/null +++ b/Documentation/RelNotes/1.7.7.5.txt @@ -0,0 +1,14 @@ +Git v1.7.7.5 Release Notes +========================== + +Fixes since v1.7.7.4 +-------------------- + + * After fetching from a remote that has very long refname, the reporting + output could have corrupted by overrunning a static buffer. + + * "git checkout" and "git merge" treated in-tree .gitignore and exclude + file in $GIT_DIR/info/ directory inconsistently when deciding which + untracked files are ignored and expendable. + +Also contains minor fixes and documentation updates. diff --git a/Documentation/git.txt b/Documentation/git.txt index 4a29f47..5c313e5 100644 --- a/Documentation/git.txt +++ b/Documentation/git.txt @@ -44,9 +44,13 @@ unreleased) version of git, that is available from 'master' branch of the `git.git` repository. Documentation for older releases are available here: -* link:v1.7.7.1/git.html[documentation for release 1.7.7.1] +* link:v1.7.7.5/git.html[documentation for release 1.7.7.5] * release notes for + link:RelNotes/1.7.7.5.txt[1.7.7.5], + link:RelNotes/1.7.7.4.txt[1.7.7.4], + link:RelNotes/1.7.7.3.txt[1.7.7.3], + link:RelNotes/1.7.7.2.txt[1.7.7.2], link:RelNotes/1.7.7.1.txt[1.7.7.1], link:RelNotes/1.7.7.txt[1.7.7]. diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN index d0ec749..7b7ac91 100755 --- a/GIT-VERSION-GEN +++ b/GIT-VERSION-GEN @@ -1,7 +1,7 @@ #!/bin/sh GVF=GIT-VERSION-FILE -DEF_VER=v1.7.7.4 +DEF_VER=v1.7.7.5 LF=' ' diff --git a/RelNotes b/RelNotes index 907613e..cd6bf00 120000 --- a/RelNotes +++ b/RelNotes @@ -1 +1 @@ -Documentation/RelNotes/1.7.7.4.txt \ No newline at end of file +Documentation/RelNotes/1.7.7.5.txt \ No newline at end of file -- cgit v0.10.2-6-g49f6