From 8ab40a20053aa4a0f8d92d08ece88ff09b771435 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Fri, 23 Feb 2007 20:12:33 +0300 Subject: git-show-ref --verify: Fail if called without a reference builtin-show-ref.c (cmd_show_ref): Fail if called with --verify option but without a reference. Signed-off-by: Dmitry V. Levin Signed-off-by: Junio C Hamano --- builtin-show-ref.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/builtin-show-ref.c b/builtin-show-ref.c index 853f13f6ae..75211e64f9 100644 --- a/builtin-show-ref.c +++ b/builtin-show-ref.c @@ -221,9 +221,11 @@ int cmd_show_ref(int argc, const char **argv, const char *prefix) } if (verify) { - unsigned char sha1[20]; - + if (!pattern) + die("--verify requires a reference"); while (*pattern) { + unsigned char sha1[20]; + if (!strncmp(*pattern, "refs/", 5) && resolve_ref(*pattern, sha1, 1, NULL)) { if (!quiet) -- cgit v1.2.3 From bdd69c2f64d303f99b0f530263c3c04d329c2227 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santi=20B=C3=A9jar?= Date: Fri, 23 Feb 2007 17:03:43 +0100 Subject: core.legacyheaders: Use the description used in RelNotes-1.5.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It explains what it does and why, and says how to use the new format. Signed-off-by: Santi BĂ©jar Signed-off-by: Junio C Hamano --- Documentation/config.txt | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Documentation/config.txt b/Documentation/config.txt index 4a22a00b71..9fec76935e 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -192,10 +192,17 @@ core.compression:: slowest. core.legacyheaders:: - A boolean which enables the legacy object header format in case - you want to interoperate with old clients accessing the object - database directly (where the "http://" and "rsync://" protocols - count as direct access). + A boolean which + changes the format of loose objects so that they are more + efficient to pack and to send out of the repository over git + native protocol, since v1.4.2. However, loose objects + written in the new format cannot be read by git older than + that version; people fetching from your repository using + older versions of git over dumb transports (e.g. http) + will also be affected. ++ +To let git use the new loose object format, you have to +set core.legacyheaders to false. core.packedGitWindowSize:: Number of bytes of a pack file to map into memory in a -- cgit v1.2.3 From c06d2daa12f72f175e3569bbb2a5f25e5f134f5e Mon Sep 17 00:00:00 2001 From: Robin Rosenberg Date: Fri, 23 Feb 2007 23:27:58 +0100 Subject: Limit filename for format-patch Badly formatted commits may have very long comments. This causes git-format-patch to fail. To avoid that, truncate the filename to a value we believe will always work. Err out if the patch file cannot be created. Signed-off-by: Robin Rosenberg Acked-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- builtin-log.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/builtin-log.c b/builtin-log.c index af2de54371..a5e4b625f8 100644 --- a/builtin-log.c +++ b/builtin-log.c @@ -224,6 +224,9 @@ int cmd_log(int argc, const char **argv, const char *prefix) return cmd_log_walk(&rev); } +/* format-patch */ +#define FORMAT_PATCH_NAME_MAX 64 + static int istitlechar(char c) { return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || @@ -264,15 +267,18 @@ static int git_format_config(const char *var, const char *value) static FILE *realstdout = NULL; static const char *output_directory = NULL; -static void reopen_stdout(struct commit *commit, int nr, int keep_subject) +static int reopen_stdout(struct commit *commit, int nr, int keep_subject) { - char filename[1024]; + char filename[PATH_MAX]; char *sol; int len = 0; - int suffix_len = strlen(fmt_patch_suffix) + 10; /* ., NUL and slop */ + int suffix_len = strlen(fmt_patch_suffix) + 1; if (output_directory) { - strlcpy(filename, output_directory, 1000); + if (strlen(output_directory) >= + sizeof(filename) - FORMAT_PATCH_NAME_MAX - suffix_len) + return error("name of output directory is too long"); + strlcpy(filename, output_directory, sizeof(filename) - suffix_len); len = strlen(filename); if (filename[len - 1] != '/') filename[len++] = '/'; @@ -297,7 +303,8 @@ static void reopen_stdout(struct commit *commit, int nr, int keep_subject) } for (j = 0; - len < sizeof(filename) - suffix_len && + j < FORMAT_PATCH_NAME_MAX - suffix_len - 5 && + len < sizeof(filename) - suffix_len && sol[j] && sol[j] != '\n'; j++) { if (istitlechar(sol[j])) { @@ -314,10 +321,16 @@ static void reopen_stdout(struct commit *commit, int nr, int keep_subject) } while (filename[len - 1] == '.' || filename[len - 1] == '-') len--; + filename[len] = 0; } + if (len + suffix_len >= sizeof(filename)) + return error("Patch pathname too long"); strcpy(filename + len, fmt_patch_suffix); fprintf(realstdout, "%s\n", filename); - freopen(filename, "w", stdout); + if (freopen(filename, "w", stdout) == NULL) + return error("Cannot open patch file %s",filename); + return 0; + } static int get_patch_id(struct commit *commit, struct diff_options *options, @@ -573,7 +586,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) rev.message_id = message_id; } if (!use_stdout) - reopen_stdout(commit, rev.nr, keep_subject); + if (reopen_stdout(commit, rev.nr, keep_subject)) + die("Failed to create output files"); shown = log_tree_commit(&rev, commit); free(commit->buffer); commit->buffer = NULL; -- cgit v1.2.3 From b1440cc8060e79f885691ebeae7ce033bd606a7c Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 24 Feb 2007 01:05:27 -0800 Subject: Reword git-am 3-way fallback failure message. When the blobs recorded on the index lines in the patch as pre-image blobs are not found in the repository, "git-am" punted saying that the index line does not record anything useful. This was not clear enough -- the index line does have something useful but the problem was that it was not useful in _that_ repository. Reword the message as Francis Moreau suggests. Signed-off-by: Junio C Hamano --- git-am.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-am.sh b/git-am.sh index 6db9cb503a..2c73d116b2 100755 --- a/git-am.sh +++ b/git-am.sh @@ -66,7 +66,7 @@ fall_back_3way () { git-update-index -z --index-info <"$dotest/patch-merge-index-info" && GIT_INDEX_FILE="$dotest/patch-merge-tmp-index" \ git-write-tree >"$dotest/patch-merge-base+" || - cannot_fallback "Patch does not record usable index information." + cannot_fallback "Repository lacks necessary blobs to fall back on 3-way merge." echo Using index info to reconstruct a base tree... if GIT_INDEX_FILE="$dotest/patch-merge-tmp-index" \ -- cgit v1.2.3 From 5089277718503a4de7817b5f6754cb03116d5524 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 23 Feb 2007 03:44:30 -0800 Subject: diff-patch: Avoid emitting double-slashes in textual patch. Signed-off-by: Junio C Hamano --- diff.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/diff.c b/diff.c index 13b9b6c560..b8a90e91a9 100644 --- a/diff.c +++ b/diff.c @@ -211,6 +211,8 @@ static void emit_rewrite_diff(const char *name_a, diff_populate_filespec(two, 0); lc_a = count_lines(one->data, one->size); lc_b = count_lines(two->data, two->size); + name_a += (*name_a == '/'); + name_b += (*name_b == '/'); printf("--- a/%s\n+++ b/%s\n@@ -", name_a, name_b); print_line_count(lc_a); printf(" +"); @@ -1020,8 +1022,8 @@ static void builtin_diff(const char *name_a, const char *set = diff_get_color(o->color_diff, DIFF_METAINFO); const char *reset = diff_get_color(o->color_diff, DIFF_RESET); - a_one = quote_two("a/", name_a); - b_two = quote_two("b/", name_b); + a_one = quote_two("a/", name_a + (*name_a == '/')); + b_two = quote_two("b/", name_b + (*name_b == '/')); lbl[0] = DIFF_FILE_VALID(one) ? a_one : "/dev/null"; lbl[1] = DIFF_FILE_VALID(two) ? b_two : "/dev/null"; printf("%sdiff --git %s %s%s\n", set, a_one, b_two, reset); -- cgit v1.2.3