* git-push error: Cannot write keep file
@ 2009-02-24 17:04 Rafael Darder Calvo
2009-02-24 17:31 ` Junio C Hamano
0 siblings, 1 reply; 10+ messages in thread
From: Rafael Darder Calvo @ 2009-02-24 17:04 UTC (permalink / raw)
To: git
[-- Attachment #1: Type: text/plain, Size: 834 bytes --]
Hello,
I am having the following error when I try to git push.
rdarder@shiny:~/Sources/promotoras$ git push origin ranto:ranto
Counting objects: 256, done.
Compressing objects: 100% (199/199), done.
Writing objects: 100% (213/213), 216.94 KiB, done.
Total 213 (delta 60), reused 1 (delta 0)
fatal: cannot write keep file
error: unpack failed: index-pack abnormal exit
To ssh://fherrero@10.7.1.20:2222/var/www/promotoras.git
! [remote rejected] ranto -> ranto (n/a (unpacker error))
error: failed to push some refs to
'ssh://fherrero@10.7.1.20:2222/var/www/promotoras.git'
I couldn't find any significant description on the error "cannot write
keep file". git-fsck passes without errors in both repositories, and I
find no permission problems. Can anyone give me some directions on how
to diagnose this?
Regards,
Rafael
[-- Attachment #2: rdarder.vcf --]
[-- Type: text/x-vcard, Size: 266 bytes --]
begin:vcard
fn:Rafael Darder Calvo
n:Darder Calvo;Rafael
org:;Infraestructura
adr:;;Mitre 1017 Piso 5;Rosario;Santa Fe;S2000COU;Argentina
email;internet:rdarder@spiralti.com
title:Spiralti Rosario
tel;work:+54 341 5302041
url:www.spiralti.com
version:2.1
end:vcard
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: git-push error: Cannot write keep file
2009-02-24 17:04 git-push error: Cannot write keep file Rafael Darder Calvo
@ 2009-02-24 17:31 ` Junio C Hamano
2009-02-24 21:21 ` Rafael Darder Calvo
2009-02-25 7:11 ` [PATCH v2] Make sure objects/pack exists before creating a new pack Junio C Hamano
0 siblings, 2 replies; 10+ messages in thread
From: Junio C Hamano @ 2009-02-24 17:31 UTC (permalink / raw)
To: Rafael Darder Calvo; +Cc: git
Rafael Darder Calvo <rdarder@spiralti.com> writes:
> Hello,
> I am having the following error when I try to git push.
>
>
> rdarder@shiny:~/Sources/promotoras$ git push origin ranto:ranto
> Counting objects: 256, done.
> Compressing objects: 100% (199/199), done.
> Writing objects: 100% (213/213), 216.94 KiB, done.
> Total 213 (delta 60), reused 1 (delta 0)
>
> fatal: cannot write keep file
>
> error: unpack failed: index-pack abnormal exit
> To ssh://fherrero@10.7.1.20:2222/var/www/promotoras.git
> ! [remote rejected] ranto -> ranto (n/a (unpacker error))
> error: failed to push some refs to
> 'ssh://fherrero@10.7.1.20:2222/var/www/promotoras.git'
>
>
> I couldn't find any significant description on the error "cannot write
> keep file". git-fsck passes without errors in both repositories, and I
> find no permission problems. Can anyone give me some directions on how
> to diagnose this?
If you have access to the receiving side of the repository and the machine
that hosts it, the debug patch attached may help.
One possibility is the receiving repository was initialized long time ago
with an ancient git (ealier than f49fb35 (git-init-db: create "pack"
subdirectory under objects, 2005-06-27), and never had a packfile in it
since then. We started creating '.git/objects/pack/' subdirectory in
git-init only after that commit. It was Ok for a long time because we
lazily create "pack" subdirectory as needed, but a recent change 8b4eb6b
(Do not perform cross-directory renames when creating packs, 2008-09-22)
carelessly assumed that .git/objects/pack/ directory would always exist
and tries to create files in there without making sure the leading
directories exist. See $gmane/110621
Subject: [PATCH] Make sure objects/pack exists before creating a new pack
To: git@vger.kernel.org
Date: Wed, 18 Feb 2009 20:48:07 -0800
Message-ID: <7vr61vnibc.fsf@gitster.siamese.dyndns.org>
for details.
And the debug patch...
index-pack.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/index-pack.c b/index-pack.c
index f7a3807..acdc85f 100644
--- a/index-pack.c
+++ b/index-pack.c
@@ -802,14 +802,18 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
keep_fd = open(keep_name, O_RDWR|O_CREAT|O_EXCL, 0600);
if (keep_fd < 0) {
if (errno != EEXIST)
- die("cannot write keep file");
+ die("cannot write keep file '%s' (%s)",
+ keep_name,
+ strerror(errno));
} else {
if (keep_msg_len > 0) {
write_or_die(keep_fd, keep_msg, keep_msg_len);
write_or_die(keep_fd, "\n", 1);
}
if (close(keep_fd) != 0)
- die("cannot write keep file");
+ die("cannot close the written keep file '%s' (%s)",
+ keep_name,
+ strerror(errno));
report = "keep";
}
}
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: git-push error: Cannot write keep file
2009-02-24 17:31 ` Junio C Hamano
@ 2009-02-24 21:21 ` Rafael Darder Calvo
2009-02-25 7:11 ` [PATCH v2] Make sure objects/pack exists before creating a new pack Junio C Hamano
1 sibling, 0 replies; 10+ messages in thread
From: Rafael Darder Calvo @ 2009-02-24 21:21 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
[-- Attachment #1: Type: text/plain, Size: 3222 bytes --]
Junio C Hamano wrote:
> Rafael Darder Calvo <rdarder@spiralti.com> writes:
>
>> Hello,
>> I am having the following error when I try to git push.
>>
>>
>> rdarder@shiny:~/Sources/promotoras$ git push origin ranto:ranto
>> Counting objects: 256, done.
>> Compressing objects: 100% (199/199), done.
>> Writing objects: 100% (213/213), 216.94 KiB, done.
>> Total 213 (delta 60), reused 1 (delta 0)
>>
>> fatal: cannot write keep file
>>
>> error: unpack failed: index-pack abnormal exit
>> To ssh://fherrero@10.7.1.20:2222/var/www/promotoras.git
>> ! [remote rejected] ranto -> ranto (n/a (unpacker error))
>> error: failed to push some refs to
>> 'ssh://fherrero@10.7.1.20:2222/var/www/promotoras.git'
>>
>>
>> I couldn't find any significant description on the error "cannot write
>> keep file". git-fsck passes without errors in both repositories, and I
>> find no permission problems. Can anyone give me some directions on how
>> to diagnose this?
>
> If you have access to the receiving side of the repository and the machine
> that hosts it, the debug patch attached may help.
>
> One possibility is the receiving repository was initialized long time ago
> with an ancient git (ealier than f49fb35 (git-init-db: create "pack"
> subdirectory under objects, 2005-06-27), and never had a packfile in it
> since then. We started creating '.git/objects/pack/' subdirectory in
> git-init only after that commit. It was Ok for a long time because we
> lazily create "pack" subdirectory as needed, but a recent change 8b4eb6b
> (Do not perform cross-directory renames when creating packs, 2008-09-22)
> carelessly assumed that .git/objects/pack/ directory would always exist
> and tries to create files in there without making sure the leading
> directories exist. See $gmane/110621
The receiving repository was indeed lacking a .git/objects/pack/
directory, but it was created with a recent (1.5.4.3) git version. I
suspect the repo owner has deleted de dir by mistake or something.
Thank you very much for your help.
>
> Subject: [PATCH] Make sure objects/pack exists before creating a new pack
> To: git@vger.kernel.org
> Date: Wed, 18 Feb 2009 20:48:07 -0800
> Message-ID: <7vr61vnibc.fsf@gitster.siamese.dyndns.org>
>
> for details.
>
> And the debug patch...
>
> index-pack.c | 8 ++++++--
> 1 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/index-pack.c b/index-pack.c
> index f7a3807..acdc85f 100644
> --- a/index-pack.c
> +++ b/index-pack.c
> @@ -802,14 +802,18 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
> keep_fd = open(keep_name, O_RDWR|O_CREAT|O_EXCL, 0600);
> if (keep_fd < 0) {
> if (errno != EEXIST)
> - die("cannot write keep file");
> + die("cannot write keep file '%s' (%s)",
> + keep_name,
> + strerror(errno));
> } else {
> if (keep_msg_len > 0) {
> write_or_die(keep_fd, keep_msg, keep_msg_len);
> write_or_die(keep_fd, "\n", 1);
> }
> if (close(keep_fd) != 0)
> - die("cannot write keep file");
> + die("cannot close the written keep file '%s' (%s)",
> + keep_name,
> + strerror(errno));
> report = "keep";
> }
> }
>
>
>
>
>
[-- Attachment #2: rdarder.vcf --]
[-- Type: text/x-vcard, Size: 266 bytes --]
begin:vcard
fn:Rafael Darder Calvo
n:Darder Calvo;Rafael
org:;Infraestructura
adr:;;Mitre 1017 Piso 5;Rosario;Santa Fe;S2000COU;Argentina
email;internet:rdarder@spiralti.com
title:Spiralti Rosario
tel;work:+54 341 5302041
url:www.spiralti.com
version:2.1
end:vcard
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2] Make sure objects/pack exists before creating a new pack
2009-02-24 17:31 ` Junio C Hamano
2009-02-24 21:21 ` Rafael Darder Calvo
@ 2009-02-25 7:11 ` Junio C Hamano
2009-02-25 7:15 ` Junio C Hamano
2009-02-26 9:19 ` Johannes Sixt
1 sibling, 2 replies; 10+ messages in thread
From: Junio C Hamano @ 2009-02-25 7:11 UTC (permalink / raw)
To: git; +Cc: Todd Zullinger, Rafael Darder Calvo
In a repository created with git older than f49fb35 (git-init-db: create
"pack" subdirectory under objects, 2005-06-27), objects/pack/ directory is
not created upon initialization. It was Ok because subdirectories are
created as needed inside directories init-db creates, and back then,
packfiles were recent invention.
After the said commit, new codepaths started relying on the presense of
objects/pack/ directory in the repository. This was exacerbated with
8b4eb6b (Do not perform cross-directory renames when creating packs,
2008-09-22) that moved the location temporary pack files are created from
objects/ directory to objects/pack/ directory, because moving temporary to
the final location was done carefully with lazy leading directory creation.
Many packfile related operations in such an old repository can fail
mysteriously because of this.
This commit introduces two helper functions to make things work better.
- odb_mkstemp() is a specialized version of mkstemp() to refactor the
code and teach it to create leading directories as needed;
- odb_pack_keep() refactors the code to create a ".keep" file while
create leading directories as needed.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
* This is a re-roll of the earlier patch in response to Fedora bugzilla
entry https://bugzilla.redhat.com/show_bug.cgi?id=483546
The earlier one didn't cover the objects/pack/pack-*.keep codepaths, and
wouldn't have been sufficient to fix the breakage reported by
$gmane/111316.
This is meant to apply cleanly to the v1.6.0.X maintenance track and
upwards.
builtin-pack-objects.c | 5 ++---
fast-import.c | 14 +++++---------
git-compat-util.h | 2 ++
index-pack.c | 23 ++++++++++++-----------
pack-write.c | 6 ++----
t/t5300-pack-object.sh | 17 +++++++++++++++++
wrapper.c | 32 ++++++++++++++++++++++++++++++++
7 files changed, 72 insertions(+), 27 deletions(-)
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index fb5e14d..7518d53 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -473,9 +473,8 @@ static void write_pack_file(void)
} else {
char tmpname[PATH_MAX];
int fd;
- snprintf(tmpname, sizeof(tmpname),
- "%s/pack/tmp_pack_XXXXXX", get_object_directory());
- fd = xmkstemp(tmpname);
+ fd = odb_mkstemp(tmpname, sizeof(tmpname),
+ "pack/tmp_pack_XXXXXX");
pack_tmp_name = xstrdup(tmpname);
f = sha1fd(fd, pack_tmp_name);
}
diff --git a/fast-import.c b/fast-import.c
index 5bc9ce2..3f92194 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -815,9 +815,8 @@ static void start_packfile(void)
struct pack_header hdr;
int pack_fd;
- snprintf(tmpfile, sizeof(tmpfile),
- "%s/pack/tmp_pack_XXXXXX", get_object_directory());
- pack_fd = xmkstemp(tmpfile);
+ pack_fd = odb_mkstemp(tmpfile, sizeof(tmpfile),
+ "pack/tmp_pack_XXXXXX");
p = xcalloc(1, sizeof(*p) + strlen(tmpfile) + 2);
strcpy(p->pack_name, tmpfile);
p->pack_fd = pack_fd;
@@ -877,9 +876,8 @@ static char *create_index(void)
c = next;
}
- snprintf(tmpfile, sizeof(tmpfile),
- "%s/pack/tmp_idx_XXXXXX", get_object_directory());
- idx_fd = xmkstemp(tmpfile);
+ idx_fd = odb_mkstemp(tmpfile, sizeof(tmpfile),
+ "pack/tmp_idx_XXXXXX");
f = sha1fd(idx_fd, tmpfile);
sha1write(f, array, 256 * sizeof(int));
SHA1_Init(&ctx);
@@ -905,9 +903,7 @@ static char *keep_pack(char *curr_index_name)
chmod(pack_data->pack_name, 0444);
chmod(curr_index_name, 0444);
- snprintf(name, sizeof(name), "%s/pack/pack-%s.keep",
- get_object_directory(), sha1_to_hex(pack_data->sha1));
- keep_fd = open(name, O_RDWR|O_CREAT|O_EXCL, 0600);
+ keep_fd = odb_pack_keep(name, sizeof(name), pack_data->sha1);
if (keep_fd < 0)
die("cannot create keep file");
write_or_die(keep_fd, keep_msg, strlen(keep_msg));
diff --git a/git-compat-util.h b/git-compat-util.h
index cf89cdf..758a880 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -294,6 +294,8 @@ extern ssize_t xwrite(int fd, const void *buf, size_t len);
extern int xdup(int fd);
extern FILE *xfdopen(int fd, const char *mode);
extern int xmkstemp(char *template);
+extern int odb_mkstemp(char *template, size_t limit, const char *pattern);
+extern int odb_pack_keep(char *name, size_t namesz, unsigned char *sha1);
static inline size_t xsize_t(off_t len)
{
diff --git a/index-pack.c b/index-pack.c
index c99a1a1..745ac0b 100644
--- a/index-pack.c
+++ b/index-pack.c
@@ -171,9 +171,8 @@ static char *open_pack_file(char *pack_name)
input_fd = 0;
if (!pack_name) {
static char tmpfile[PATH_MAX];
- snprintf(tmpfile, sizeof(tmpfile),
- "%s/pack/tmp_pack_XXXXXX", get_object_directory());
- output_fd = xmkstemp(tmpfile);
+ output_fd = odb_mkstemp(tmpfile, sizeof(tmpfile),
+ "pack/tmp_pack_XXXXXX");
pack_name = xstrdup(tmpfile);
} else
output_fd = open(pack_name, O_CREAT|O_EXCL|O_RDWR, 0600);
@@ -795,22 +794,24 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
if (keep_msg) {
int keep_fd, keep_msg_len = strlen(keep_msg);
- if (!keep_name) {
- snprintf(name, sizeof(name), "%s/pack/pack-%s.keep",
- get_object_directory(), sha1_to_hex(sha1));
- keep_name = name;
- }
- keep_fd = open(keep_name, O_RDWR|O_CREAT|O_EXCL, 0600);
+
+ if (!keep_name)
+ keep_fd = odb_pack_keep(name, sizeof(name), sha1);
+ else
+ keep_fd = open(keep_name, O_RDWR|O_CREAT|O_EXCL, 0600);
+
if (keep_fd < 0) {
if (errno != EEXIST)
- die("cannot write keep file");
+ die("cannot write keep file '%s' (%s)",
+ keep_name, strerror(errno));
} else {
if (keep_msg_len > 0) {
write_or_die(keep_fd, keep_msg, keep_msg_len);
write_or_die(keep_fd, "\n", 1);
}
if (close(keep_fd) != 0)
- die("cannot write keep file");
+ die("cannot close written keep file '%s' (%s)",
+ keep_name, strerror(errno));
report = "keep";
}
}
diff --git a/pack-write.c b/pack-write.c
index 3621f1d..e82c025 100644
--- a/pack-write.c
+++ b/pack-write.c
@@ -44,9 +44,7 @@ char *write_idx_file(char *index_name, struct pack_idx_entry **objects,
if (!index_name) {
static char tmpfile[PATH_MAX];
- snprintf(tmpfile, sizeof(tmpfile),
- "%s/pack/tmp_idx_XXXXXX", get_object_directory());
- fd = xmkstemp(tmpfile);
+ fd = odb_mkstemp(tmpfile, sizeof(tmpfile), "pack/tmp_idx_XXXXXX");
index_name = xstrdup(tmpfile);
} else {
unlink(index_name);
@@ -239,7 +237,7 @@ char *index_pack_lockfile(int ip_out)
char packname[46];
/*
- * The first thing we expects from index-pack's output
+ * The first thing we expect from index-pack's output
* is "pack\t%40s\n" or "keep\t%40s\n" (46 bytes) where
* %40s is the newly created pack SHA1 name. In the "keep"
* case, we need it to remove the corresponding .keep file
diff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh
index 2852a03..73d871c 100755
--- a/t/t5300-pack-object.sh
+++ b/t/t5300-pack-object.sh
@@ -180,6 +180,23 @@ test_expect_success \
unset GIT_OBJECT_DIRECTORY
+test_expect_success 'survive missing objects/pack directory' '
+ (
+ rm -fr missing-pack &&
+ mkdir missing-pack &&
+ cd missing-pack &&
+ git init &&
+ GOP=.git/objects/pack
+ rm -fr $GOP &&
+ git index-pack --stdin --keep=test <../test-3-${packname_3}.pack &&
+ test -f $GOP/pack-${packname_3}.pack &&
+ test_cmp $GOP/pack-${packname_3}.pack ../test-3-${packname_3}.pack &&
+ test -f $GOP/pack-${packname_3}.idx &&
+ test_cmp $GOP/pack-${packname_3}.idx ../test-3-${packname_3}.idx &&
+ test -f $GOP/pack-${packname_3}.keep
+ )
+'
+
test_expect_success \
'verify pack' \
'git verify-pack test-1-${packname_1}.idx \
diff --git a/wrapper.c b/wrapper.c
index 93562f0..231a58f 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -196,3 +196,35 @@ int xmkstemp(char *template)
die("Unable to create temporary file: %s", strerror(errno));
return fd;
}
+
+int odb_mkstemp(char *template, size_t limit, const char *pattern)
+{
+ int fd;
+
+ snprintf(template, limit, "%s/%s",
+ get_object_directory(), pattern);
+ fd = mkstemp(template);
+ if (0 <= fd)
+ return fd;
+
+ /* slow path */
+ safe_create_leading_directories(template);
+ snprintf(template, limit, "%s/%s",
+ get_object_directory(), pattern);
+ return xmkstemp(template);
+}
+
+int odb_pack_keep(char *name, size_t namesz, unsigned char *sha1)
+{
+ int fd;
+
+ snprintf(name, namesz, "%s/pack/pack-%s.keep",
+ get_object_directory(), sha1_to_hex(sha1));
+ fd = open(name, O_RDWR|O_CREAT|O_EXCL, 0600);
+ if (0 <= fd)
+ return fd;
+
+ /* slow path */
+ safe_create_leading_directories(name);
+ return open(name, O_RDWR|O_CREAT|O_EXCL, 0600);
+}
--
1.6.2.rc1.113.ga620b
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v2] Make sure objects/pack exists before creating a new pack
2009-02-25 7:11 ` [PATCH v2] Make sure objects/pack exists before creating a new pack Junio C Hamano
@ 2009-02-25 7:15 ` Junio C Hamano
2009-02-26 9:19 ` Johannes Sixt
1 sibling, 0 replies; 10+ messages in thread
From: Junio C Hamano @ 2009-02-25 7:15 UTC (permalink / raw)
To: git; +Cc: Todd Zullinger, Rafael Darder Calvo
This is *not* to be applied, but to document and demonstrate how I tested
the previous fix. It disables the creation of .git/objects/pack/
directory when "git init" is run, and adds minimum workaround in the tests
that assume the directory is always created.
---
builtin-init-db.c | 2 +-
t/t0000-basic.sh | 2 +-
t/t5300-pack-object.sh | 1 +
3 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/builtin-init-db.c b/builtin-init-db.c
index d30c3fe..e5fc4c1 100644
--- a/builtin-init-db.c
+++ b/builtin-init-db.c
@@ -301,7 +301,7 @@ int init_db(const char *template_dir, unsigned int flags)
safe_create_dir(sha1_dir, 1);
strcpy(path+len, "/pack");
- safe_create_dir(path, 1);
+/* safe_create_dir(path, 1); */
strcpy(path+len, "/info");
safe_create_dir(path, 1);
diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index 70df15c..6240ca4 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -42,7 +42,7 @@ test_expect_success \
# also it should have 2 subdirectories; no fan-out anymore, pack, and info.
# 3 is counting "objects" itself
find .git/objects -type d -print >full-of-directories
-test_expect_success \
+: test_expect_success \
'.git/objects should have 3 subdirectories.' \
'test $(wc -l < full-of-directories) = 3'
diff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh
index 73d871c..e7d8daf 100755
--- a/t/t5300-pack-object.sh
+++ b/t/t5300-pack-object.sh
@@ -138,6 +138,7 @@ test_expect_success \
'GIT_OBJECT_DIRECTORY=.git2/objects &&
export GIT_OBJECT_DIRECTORY &&
git init &&
+ mkdir -p .git2/objects/pack &&
cp test-1-${packname_1}.pack test-1-${packname_1}.idx .git2/objects/pack && {
git diff-tree --root -p $commit &&
while read object
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v2] Make sure objects/pack exists before creating a new pack
2009-02-25 7:11 ` [PATCH v2] Make sure objects/pack exists before creating a new pack Junio C Hamano
2009-02-25 7:15 ` Junio C Hamano
@ 2009-02-26 9:19 ` Johannes Sixt
2009-02-26 11:19 ` Mike Ralphson
1 sibling, 1 reply; 10+ messages in thread
From: Johannes Sixt @ 2009-02-26 9:19 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Todd Zullinger, Rafael Darder Calvo
Junio C Hamano schrieb:
> @@ -795,22 +794,24 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
>
> if (keep_msg) {
> int keep_fd, keep_msg_len = strlen(keep_msg);
> - if (!keep_name) {
> - snprintf(name, sizeof(name), "%s/pack/pack-%s.keep",
> - get_object_directory(), sha1_to_hex(sha1));
> - keep_name = name;
You should not have removed this line...
> - }
> - keep_fd = open(keep_name, O_RDWR|O_CREAT|O_EXCL, 0600);
> +
> + if (!keep_name)
> + keep_fd = odb_pack_keep(name, sizeof(name), sha1);
> + else
> + keep_fd = open(keep_name, O_RDWR|O_CREAT|O_EXCL, 0600);
> +
> if (keep_fd < 0) {
> if (errno != EEXIST)
> - die("cannot write keep file");
> + die("cannot write keep file '%s' (%s)",
> + keep_name, strerror(errno));
... we need keep_name for this error message.
Warning: I did not test the failure path; but I made sure that these
tests pass on Windows:
cd t && make *fetch* *pack* *index* *pull*
-- snip --
From: Johannes Sixt <j6t@kdbg.org>
Subject: [PATCH] index-pack: Set keep_name if a new keep file was allocated
6e180cdc (Make sure objects/pack exists before creating a new pack,
2009-02-25) simplified the code in this area, but it also extended an
error message to include the file name that caused the error. However,
one code path did not set file name correctly.
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
---
index-pack.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/index-pack.c b/index-pack.c
index 7fee872..93a09c6 100644
--- a/index-pack.c
+++ b/index-pack.c
@@ -794,9 +794,10 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
if (keep_msg) {
int keep_fd, keep_msg_len = strlen(keep_msg);
- if (!keep_name)
+ if (!keep_name) {
keep_fd = odb_pack_keep(name, sizeof(name), sha1);
- else
+ keep_name = name;
+ } else
keep_fd = open(keep_name, O_RDWR|O_CREAT|O_EXCL, 0600);
if (keep_fd < 0) {
--
1.6.2.rc2.1005.gb0117
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v2] Make sure objects/pack exists before creating a new pack
2009-02-26 9:19 ` Johannes Sixt
@ 2009-02-26 11:19 ` Mike Ralphson
2009-02-26 15:31 ` Johannes Sixt
0 siblings, 1 reply; 10+ messages in thread
From: Mike Ralphson @ 2009-02-26 11:19 UTC (permalink / raw)
To: Johannes Sixt, Junio C Hamano; +Cc: git, Todd Zullinger, Rafael Darder Calvo
2009/2/26 Johannes Sixt <j.sixt@viscovery.net>
>
> Junio C Hamano schrieb:
> > @@ -795,22 +794,24 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
> >
> > if (keep_msg) {
> > int keep_fd, keep_msg_len = strlen(keep_msg);
> > - if (!keep_name) {
> > - snprintf(name, sizeof(name), "%s/pack/pack-%s.keep",
> > - get_object_directory(), sha1_to_hex(sha1));
> > - keep_name = name;
>
> You should not have removed this line...
Even with j6t's patch, I'm seeing failures in t5300--pack-object.sh on AIX 5.3
* FAIL 15: survive missing objects/pack directory
fatal: Unable to create temporary file (): No such file or directory
From a bit of instrumenting (no working gdb here), I see that in
wrapper.c/odb_mkstemp, template is empty on entry, empty before the
call to safe_create_leading_directories, but contains
.git/objects/pack/tmp_pack_XXXXXX after the second snprintf. TMPDIR is
not set here, which I thought might be the root cause, but it doesn't
seem to be that.
My naive solution is to:
index b07cdf2..80fee48 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -268,9 +268,9 @@ int odb_mkstemp(char *template, size_t limit,
const char *pattern)
return fd;
/* slow path */
- safe_create_leading_directories(template);
snprintf(template, limit, "%s/%s",
get_object_directory(), pattern);
+ safe_create_leading_directories(template);
return xmkstemp(template);
}
Which then passes all tests.
Bearing in mind that for me, fiddling with C is like trying to order
room service in Latin, if this is in any way the correct thing to do,
I'll post a proper patch with s-o-b if required, or you can just
squash into j6t's.
Mike
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v2] Make sure objects/pack exists before creating a new pack
2009-02-26 11:19 ` Mike Ralphson
@ 2009-02-26 15:31 ` Johannes Sixt
2009-02-26 15:54 ` Mike Ralphson
0 siblings, 1 reply; 10+ messages in thread
From: Johannes Sixt @ 2009-02-26 15:31 UTC (permalink / raw)
To: Mike Ralphson; +Cc: Junio C Hamano, git, Todd Zullinger, Rafael Darder Calvo
Mike Ralphson schrieb:
> 2009/2/26 Johannes Sixt <j.sixt@viscovery.net>
>> Junio C Hamano schrieb:
>>> @@ -795,22 +794,24 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
>>>
>>> if (keep_msg) {
>>> int keep_fd, keep_msg_len = strlen(keep_msg);
>>> - if (!keep_name) {
>>> - snprintf(name, sizeof(name), "%s/pack/pack-%s.keep",
>>> - get_object_directory(), sha1_to_hex(sha1));
>>> - keep_name = name;
>> You should not have removed this line...
>
> Even with j6t's patch, I'm seeing failures in t5300--pack-object.sh on AIX 5.3
>
> * FAIL 15: survive missing objects/pack directory
> fatal: Unable to create temporary file (): No such file or directory
I can confirm this. Your patch is good. I wrapped it up:
-- snip --
From: Mike Ralphson <mike.ralphson@gmail.com>
Subject: [PATCH] Fix odb_mkstemp() on AIX
The AIX mkstemp() modifies its template parameter to an empty string if
the call fails. The existing code had already recomputed the template,
but too late to be good.
See also 6ff6af62, which fixed this problem in a different spot.
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
---
wrapper.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/wrapper.c b/wrapper.c
index b07cdf2..d8efb13 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -268,9 +268,10 @@ int odb_mkstemp(char *template, size_t limit,
return fd;
/* slow path */
- safe_create_leading_directories(template);
+ /* some mkstemp implementations erase template on failure */
snprintf(template, limit, "%s/%s",
get_object_directory(), pattern);
+ safe_create_leading_directories(template);
return xmkstemp(template);
}
--
1.6.1.rc1.5.gf691f
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v2] Make sure objects/pack exists before creating a new pack
2009-02-26 15:31 ` Johannes Sixt
@ 2009-02-26 15:54 ` Mike Ralphson
2009-02-26 17:07 ` Junio C Hamano
0 siblings, 1 reply; 10+ messages in thread
From: Mike Ralphson @ 2009-02-26 15:54 UTC (permalink / raw)
To: Johannes Sixt, Junio C Hamano
Cc: git, Todd Zullinger, Rafael Darder Calvo, mike
2009/2/26 Johannes Sixt <j.sixt@viscovery.net>:
> Mike Ralphson schrieb:
>> Even with j6t's patch, I'm seeing failures in t5300--pack-object.sh on AIX 5.3
>>
>> * FAIL 15: survive missing objects/pack directory
>> fatal: Unable to create temporary file (): No such file or directory
>
> I can confirm this. Your patch is good. I wrapped it up:
>
> -- snip --
> From: Mike Ralphson <mike.ralphson@gmail.com>
> Subject: [PATCH] Fix odb_mkstemp() on AIX
>
> The AIX mkstemp() modifies its template parameter to an empty string if
> the call fails. The existing code had already recomputed the template,
> but too late to be good.
>
> See also 6ff6af62, which fixed this problem in a different spot.
Ah, I should have remembered that one.
If my $DAYJOB email address could be used in the From, as per this s-o-b:
Signed-off-by: Mike Ralphson <mike@abacus.co.uk>
Thanks.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2] Make sure objects/pack exists before creating a new pack
2009-02-26 15:54 ` Mike Ralphson
@ 2009-02-26 17:07 ` Junio C Hamano
0 siblings, 0 replies; 10+ messages in thread
From: Junio C Hamano @ 2009-02-26 17:07 UTC (permalink / raw)
To: Mike Ralphson
Cc: Johannes Sixt, git, Todd Zullinger, Rafael Darder Calvo, mike
Mike Ralphson <mike.ralphson@gmail.com> writes:
> 2009/2/26 Johannes Sixt <j.sixt@viscovery.net>:
>> Mike Ralphson schrieb:
>>> Even with j6t's patch, I'm seeing failures in t5300--pack-object.sh on AIX 5.3
>>>
>>> * FAIL 15: survive missing objects/pack directory
>>> fatal: Unable to create temporary file (): No such file or directory
>>
>> I can confirm this. Your patch is good. I wrapped it up:
>>
>> -- snip --
>> From: Mike Ralphson <mike.ralphson@gmail.com>
>> Subject: [PATCH] Fix odb_mkstemp() on AIX
>>
>> The AIX mkstemp() modifies its template parameter to an empty string if
>> the call fails. The existing code had already recomputed the template,
>> but too late to be good.
>>
>> See also 6ff6af62, which fixed this problem in a different spot.
>
> Ah, I should have remembered that one.
>
> If my $DAYJOB email address could be used in the From, as per this s-o-b:
>
> Signed-off-by: Mike Ralphson <mike@abacus.co.uk>
Thanks.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2009-02-26 17:09 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-24 17:04 git-push error: Cannot write keep file Rafael Darder Calvo
2009-02-24 17:31 ` Junio C Hamano
2009-02-24 21:21 ` Rafael Darder Calvo
2009-02-25 7:11 ` [PATCH v2] Make sure objects/pack exists before creating a new pack Junio C Hamano
2009-02-25 7:15 ` Junio C Hamano
2009-02-26 9:19 ` Johannes Sixt
2009-02-26 11:19 ` Mike Ralphson
2009-02-26 15:31 ` Johannes Sixt
2009-02-26 15:54 ` Mike Ralphson
2009-02-26 17:07 ` Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).