Hi Philip,
On Sat, 26 Mar 2016, Philip Oakley wrote:
> Philip@PhilipOakley MINGW32 /c/git-sdk-32/usr/src/git (bundle1)
> $ git bundle create test.bndl HEAD bundle1 master next pu --since=2.weeks.ago
> fatal: ambiguous argument 'next': unknown revision or path not in the working
> tree.
> Use '--' to separate paths from revisions, like this:
> 'git <command> [<revision>...] -- [<file>...]'
> error: rev-list died
> Unlink of file 'C:/git-sdk-32/usr/src/git/test.bndl.lock' failed. Should I try
> again? (y/n) n
> warning: unable to unlink C:/git-sdk-32/usr/src/git/test.bndl.lock: Invalid
> argument
The reason is that we have technical debt in create_bundle() where it
duplicates a file handle to allow closing it twice (instead of teaching
the first code path *not* to close it).
In my tests, this hacky work-around (which you are welcome to use as a
starting point for a contribution) fixes the symptom:
-- snipsnap --
diff --git a/bundle.c b/bundle.c
index 506ac49..cc2db63 100644
--- a/bundle.c
+++ b/bundle.c
@@ -399,6 +399,16 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)
return ref_count;
}
+static int bundle_fd_dup = -1;
+
+static void close_bundle_fd_dup(void)
+{
+ if (bundle_fd_dup >= 0) {
+ close(bundle_fd_dup);
+ bundle_fd_dup = -1;
+ }
+}
+
int create_bundle(struct bundle_header *header, const char *path,
int argc, const char **argv)
{
@@ -421,9 +431,10 @@ int create_bundle(struct bundle_header *header, const char *path,
* lockfile's fd. So make a copy of the file
* descriptor to avoid trying to close it twice.
*/
- bundle_fd = dup(bundle_fd);
+ bundle_fd_dup = bundle_fd = dup(bundle_fd);
if (bundle_fd < 0)
die_errno("unable to dup file descriptor");
+ atexit(close_bundle_fd_dup);
}
/* write signature */
@@ -455,6 +466,7 @@ int create_bundle(struct bundle_header *header, const
char *path,
return -1;
if (!bundle_to_stdout) {
+ bundle_fd_dup = -1;
if (commit_lock_file(&lock))
die_errno(_("cannot create '%s'"), path);
}