From: Junio C Hamano Date: Fri, 29 May 2009 22:01:16 +0000 (-0700) Subject: Merge branch 'sb/maint-1.6.2-opt-filename-fix' X-Git-Tag: v1.6.4-rc0~110 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/9affecbc89538b6fd63f772b6f14047bced9345e?hp=-c Merge branch 'sb/maint-1.6.2-opt-filename-fix' * sb/maint-1.6.2-opt-filename-fix: apply, fmt-merge-msg: use relative filenames commit: -F overrides -t --- 9affecbc89538b6fd63f772b6f14047bced9345e diff --combined builtin-apply.c index 8a3771e87e,472865b7f1..a40b982242 --- a/builtin-apply.c +++ b/builtin-apply.c @@@ -2394,7 -2394,7 +2394,7 @@@ static int check_to_create_blob(const c * In such a case, path "new_name" does not exist as * far as git is concerned. */ - if (has_symlink_leading_path(strlen(new_name), new_name)) + if (has_symlink_leading_path(new_name, strlen(new_name))) return 0; return error("%s: already exists in working directory", new_name); @@@ -2487,7 -2487,7 +2487,7 @@@ static int check_preimage(struct patch if ((st_mode ^ patch->old_mode) & S_IFMT) return error("%s: wrong type", old_name); if (st_mode != patch->old_mode) - fprintf(stderr, "warning: %s has type %o, expected %o\n", + warning("%s has type %o, expected %o", old_name, st_mode, patch->old_mode); if (!patch->new_mode && !patch->is_delete) patch->new_mode = st_mode; @@@ -2781,7 -2781,7 +2781,7 @@@ static void remove_file(struct patch *p if (rmdir(patch->old_name)) warning("unable to remove submodule %s", patch->old_name); - } else if (!unlink(patch->old_name) && rmdir_empty) { + } else if (!unlink_or_warn(patch->old_name) && rmdir_empty) { remove_path(patch->old_name); } } @@@ -2891,7 -2891,7 +2891,7 @@@ static void create_one_file(char *path if (!try_create_file(newpath, mode, buf, size)) { if (!rename(newpath, path)) return; - unlink(newpath); + unlink_or_warn(newpath); break; } if (errno != EEXIST) @@@ -2971,7 -2971,8 +2971,7 @@@ static int write_out_one_reject(struct cnt = strlen(patch->new_name); if (ARRAY_SIZE(namebuf) <= cnt + 5) { cnt = ARRAY_SIZE(namebuf) - 5; - fprintf(stderr, - "warning: truncating .rej filename to %.*s.rej", + warning("truncating .rej filename to %.*s.rej", cnt - 1, patch->new_name); } memcpy(namebuf, patch->new_name, cnt); @@@ -3262,10 -3263,10 +3262,10 @@@ int cmd_apply(int argc, const char **ar "ignore additions made by the patch"), OPT_BOOLEAN(0, "stat", &diffstat, "instead of applying the patch, output diffstat for the input"), - OPT_BOOLEAN(0, "allow-binary-replacement", &binary, - "now no-op"), - OPT_BOOLEAN(0, "binary", &binary, - "now no-op"), + { OPTION_BOOLEAN, 0, "allow-binary-replacement", &binary, + NULL, "old option, now no-op", PARSE_OPT_HIDDEN }, + { OPTION_BOOLEAN, 0, "binary", &binary, + NULL, "old option, now no-op", PARSE_OPT_HIDDEN }, OPT_BOOLEAN(0, "numstat", &numstat, "shows number of added and deleted lines in decimal notation"), OPT_BOOLEAN(0, "summary", &summary, @@@ -3315,6 -3316,10 +3315,10 @@@ argc = parse_options(argc, argv, builtin_apply_options, apply_usage, 0); + fake_ancestor = parse_options_fix_filename(prefix, fake_ancestor); + if (fake_ancestor) + fake_ancestor = xstrdup(fake_ancestor); + if (apply_with_reject) apply = apply_verbosely = 1; if (!force_apply && (diffstat || numstat || summary || check || fake_ancestor)) @@@ -3353,8 -3358,8 +3357,8 @@@ squelch_whitespace_errors < whitespace_error) { int squelched = whitespace_error - squelch_whitespace_errors; - fprintf(stderr, "warning: squelched %d " - "whitespace error%s\n", + warning("squelched %d " + "whitespace error%s", squelched, squelched == 1 ? "" : "s"); } @@@ -3364,12 -3369,12 +3368,12 @@@ whitespace_error == 1 ? "" : "s", whitespace_error == 1 ? "s" : ""); if (applied_after_fixing_ws && apply) - fprintf(stderr, "warning: %d line%s applied after" - " fixing whitespace errors.\n", + warning("%d line%s applied after" + " fixing whitespace errors.", applied_after_fixing_ws, applied_after_fixing_ws == 1 ? "" : "s"); else if (whitespace_error) - fprintf(stderr, "warning: %d line%s add%s whitespace errors.\n", + warning("%d line%s add%s whitespace errors.", whitespace_error, whitespace_error == 1 ? "" : "s", whitespace_error == 1 ? "s" : ""); diff --combined builtin-fmt-merge-msg.c index a7883690d7,c566c2df77..fae1482ba9 --- a/builtin-fmt-merge-msg.c +++ b/builtin-fmt-merge-msg.c @@@ -256,7 -256,8 +256,7 @@@ static void shortlog(const char *name, int fmt_merge_msg(int merge_summary, struct strbuf *in, struct strbuf *out) { int limit = 20, i = 0, pos = 0; - char line[1024]; - char *p = line, *sep = ""; + char *sep = ""; unsigned char head_sha1[20]; const char *current_branch; @@@ -270,8 -271,9 +270,8 @@@ /* get a line */ while (pos < in->len) { int len; - char *newline; + char *newline, *p = in->buf + pos; - p = in->buf + pos; newline = strchr(p, '\n'); len = newline ? newline - p : strlen(p); pos += len + !!newline; @@@ -363,6 -365,7 +363,7 @@@ int cmd_fmt_merge_msg(int argc, const c argc = parse_options(argc, argv, options, fmt_merge_msg_usage, 0); if (argc > 0) usage_with_options(fmt_merge_msg_usage, options); + inpath = parse_options_fix_filename(prefix, inpath); if (inpath && strcmp(inpath, "-")) { in = fopen(inpath, "r"); diff --combined t/t6200-fmt-merge-msg.sh index 2049ab6cf8,706d93769f..42f6fff373 --- a/t/t6200-fmt-merge-msg.sh +++ b/t/t6200-fmt-merge-msg.sh @@@ -83,13 -83,13 +83,13 @@@ test_expect_success 'merge-msg test #1 ' cat >expected <actual && test_cmp expected actual @@@ -208,4 -208,36 +208,36 @@@ test_expect_success 'merge-msg test #5- test_cmp expected actual ' + test_expect_success 'merge-msg -F' ' + + git config --unset-all merge.log + git config --unset-all merge.summary + git config merge.summary yes && + + git checkout master && + setdate && + git fetch . left right && + + git fmt-merge-msg -F .git/FETCH_HEAD >actual && + test_cmp expected actual + ' + + test_expect_success 'merge-msg -F in subdirectory' ' + + git config --unset-all merge.log + git config --unset-all merge.summary + git config merge.summary yes && + + git checkout master && + setdate && + git fetch . left right && + mkdir sub && + cp .git/FETCH_HEAD sub/FETCH_HEAD && + ( + cd sub && + git fmt-merge-msg -F FETCH_HEAD >../actual + ) && + test_cmp expected actual + ' + test_done