summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Documentation/config.txt15
-rw-r--r--builtin-log.c28
-rw-r--r--builtin-show-ref.c6
-rw-r--r--diff.c6
-rwxr-xr-xgit-am.sh2
5 files changed, 41 insertions, 16 deletions
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 9d045d8832..70f548464a 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
diff --git a/builtin-log.c b/builtin-log.c
index ad1e8c054d..f43790cbce 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;
diff --git a/builtin-show-ref.c b/builtin-show-ref.c
index ae0edddac1..9463ff0e69 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 (!prefixcmp(*pattern, "refs/") &&
resolve_ref(*pattern, sha1, 1, NULL)) {
if (!quiet)
diff --git a/diff.c b/diff.c
index 5ecb122255..d1eae7214d 100644
--- a/diff.c
+++ b/diff.c
@@ -219,6 +219,8 @@ static void emit_rewrite_diff(const char *name_a,
const char *new = diff_get_color(color_diff, DIFF_FILE_NEW);
const char *reset = diff_get_color(color_diff, DIFF_RESET);
+ name_a += (*name_a == '/');
+ name_b += (*name_b == '/');
name_a_tab = strchr(name_a, ' ') ? "\t" : "";
name_b_tab = strchr(name_b, ' ') ? "\t" : "";
@@ -1064,8 +1066,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);
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" \