Skip to contentSkip to conversation

Make git archive respect core.autocrlf when creating zip format archives

PATCH In review Charles Bailey 4 participants 6 messages Jun 15, 2016 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 1a7cc4db062b7df0dae0f27b29dba66c9d917e59.1221767629.git.charles@hashpling.org

#1 lore raw

PATCH 1/1 Make git archive respect core.autocrlf when creating zip format archives

There is currently no call to git_config at the start of cmd_archive. When creating tar archives the core config is read as a side-effect of reading the tar specific config, but this doesn't happen for zip archives.

The consequence is that in a configuration with core.autocrlf set, although files in a tar archive are created with crlf line endings, files in a zip archive retain unix line endings.

---

It took me a while to find the cause of the difference in behaviour between tar and zip format archives when all the crlf fixing code seemed to be in code shared by both archiving processes. I'm 99% sure that creating zip archives from repositories with core.autocrlf set to true should create zip entries with crlf line endings but it would be good to have that confirmed.

 builtin-archive.c       |    2 ++
 t/t0024-crlf-archive.sh |    2 +-
 2 files changed, 3 insertions(+), 1 deletions(-)
builtin-archive.c +2 -0
index 5ceec43..432ce2a 100644
@@ -111,6 +111,8 @@ int cmd_archive(int argc, const char **argv, const char *prefix)
 {
 	const char *remote = NULL;
 
+	git_config(git_default_config, NULL);
+
 	remote = extract_remote_arg(&argc, argv);
 	if (remote)
 		return run_remote_archiver(remote, argc, argv);
t/t0024-crlf-archive.sh +1 -1
index 3511439..e533039 100644
@@ -33,7 +33,7 @@ if [ $? -eq 127 ]; then
 	exit
 fi
 
-test_expect_failure 'zip archive' '
+test_expect_success 'zip archive' '
 
 	git archive --format=zip HEAD >test.zip &&
 
Signature · 1 line
1.6.0.1.309.g4f56
#2 lore raw

Apologies for the bad threading headers and the weird characters in the subject.

While I though I'd remembered how git format-patch and my mail client worked together, it's obvious that I hadn't.

I'll make sure that I get it right in the final patch, but in the mean time are there any comments on this?

Charles.

#3 lore raw
In reply to Charles Bailey
Quoted 10 lines · Charles Bailey

There is currently no call to git_config at the start of cmd_archive. When creating tar archives the core config is read as a side-effect of reading the tar specific config, but this doesn't happen for zip archives.

The consequence is that in a configuration with core.autocrlf set, although files in a tar archive are created with crlf line endings, files in a zip archive retain unix line endings.

Quoted 9 lines

---

It took me a while to find the cause of the difference in behaviour between tar and zip format archives when all the crlf fixing code seemed to be in code shared by both archiving processes. I'm 99% sure that creating zip archives from repositories with core.autocrlf set to true should create zip entries with crlf line endings but it would be good to have that confirmed.

If it fixes the broken test while all the other tests still pass, I can only assume it's doing something right.

The topic is a bit long though. Could you change it to "git archive: respect core.autocrlf when creating zip archives" so that it fits comfortably in one line when running "git log" on 80 char wide terminals?

As a side-note, you needn't put "1/1" in the [PATCH] section. That's usually done to make sure patches are applied in the right order when sending a series, but since a series of 1 is kinda hard to jumble.. ;-)

Signature · 3 lines
Andreas Ericsson                   [email protected]
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231
#4 lore raw

Re: [PATCH 1/1] Make git archive respect core.autocrlf when creating ...

Quoted 2 lines · Andreas Ericsson

If it fixes the broken test while all the other tests still pass, I can only assume it's doing something right.

Only if you believe that I added a sensible test in the first place :-)

Quoted 4 lines

The topic is a bit long though. Could you change it to "git archive: respect core.autocrlf when creating zip archives" so that it fits comfortably in one line when running "git log" on 80 char wide terminals?

Sorry, I made it <= 72 chars in my commit message and then forgot that git format-patch adds the [PATCH] tag.

Quoted 4 lines

As a side-note, you needn't put "1/1" in the [PATCH] section. That's usually done to make sure patches are applied in the right order when sending a series, but since a series of 1 is kinda hard to jumble.. ;-)

I thought that the patch (a single commit) didn't really warrant a patch series - being a one liner - but I made the test 0 of 1 so that people could see the test failure first before deciding whether my proposed patch was good or not. Sorry for the confusion.

Charles.

#5 lore raw

Re: [PATCH 1/1] Make git archive respect core.autocrlf when creating ...

Quoted 4 lines · Charles Bailey

I thought that the patch (a single commit) didn't really warrant a patch series - being a one liner - but I made the test 0 of 1 so that people could see the test failure first before deciding whether my proposed patch was good or not. Sorry for the confusion.

Shouldn't the tests be part of the patch? ;) To prevent it from being broken again that is.

Signature · 3 lines
Cheers,

Sverre Rabbelier
#6 lore raw
In reply to Charles Bailey
Quoted 8 lines · Charles Bailey

There is currently no call to git_config at the start of cmd_archive. When creating tar archives the core config is read as a side-effect of reading the tar specific config, but this doesn't happen for zip archives.

The consequence is that in a configuration with core.autocrlf set, although files in a tar archive are created with crlf line endings, files in a zip archive retain unix line endings.

The patches look good, but it took me a while to realize that there are two of them (0/1 and 1/1). :)

Thanks,
René