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

6 messages from 2008-09-18 to 2008-09-18. Participants: Charles Bailey, Andreas Ericsson, René Scharfe, Sverre Rabbelier.
Thread: https://gitlist.dev/t/15578

## Charles Bailey, 2008-09-18 20:01

Subject: [PATCH 1/1] Make git archive respect core.autocrlf when creating zip format archives
Message-ID: <20080918200120.GB8631@hashpling.org>
URL: https://gitlist.dev/e/20080918200120.GB8631%40hashpling.org
In-Reply-To: <1a7cc4db062b7df0dae0f27b29dba66c9d917e59.1221767629.git.charles@hashpling.org>

```
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.

Signed-off-by: Charles Bailey <charles@hashpling.org>
---

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(-)

diff --git a/builtin-archive.c b/builtin-archive.c
index 5ceec43..432ce2a 100644
--- a/builtin-archive.c
+++ b/builtin-archive.c
@@ -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);
diff --git a/t/t0024-crlf-archive.sh b/t/t0024-crlf-archive.sh
index 3511439..e533039 100644
--- a/t/t0024-crlf-archive.sh
+++ b/t/t0024-crlf-archive.sh
@@ -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 &&
 
-- 
1.6.0.1.309.g4f56

```

## Charles Bailey, 2008-09-18 20:08

Subject: Re: [PATCH 1/1] Make git archive respect core.autocrlf when creating zip format archives
Message-ID: <20080918200811.GA9101@hashpling.org>
URL: https://gitlist.dev/e/20080918200811.GA9101%40hashpling.org
In-Reply-To: <20080918200120.GB8631@hashpling.org>

```
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.

```

## Andreas Ericsson, 2008-09-18 20:21

Subject: Re: [PATCH 1/1] Make git archive respect core.autocrlf when creating zip format archives
Message-ID: <48D2B831.8080206@op5.se>
URL: https://gitlist.dev/e/48D2B831.8080206%40op5.se
In-Reply-To: <20080918200120.GB8631@hashpling.org>

```
Charles Bailey wrote:
> 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.
> 
> Signed-off-by: Charles Bailey <charles@hashpling.org>
> ---
> 
> 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.. ;-)

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

```

## Charles Bailey, 2008-09-18 20:29

Subject: Re: [PATCH 1/1] Make git archive respect core.autocrlf when creating ...
Message-ID: <20080918202929.GA9948@hashpling.org>
URL: https://gitlist.dev/e/20080918202929.GA9948%40hashpling.org
In-Reply-To: <48D2B831.8080206@op5.se>

```
On Thu, Sep 18, 2008 at 10:21:05PM +0200, Andreas Ericsson wrote:
> 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 :-)

> 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.

> 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.

```

## René Scharfe, 2008-09-18 20:41

Subject: Re: [PATCH 1/1] Make git archive respect core.autocrlf when creating zip format archives
Message-ID: <48D2BCDC.6060809@lsrfire.ath.cx>
URL: https://gitlist.dev/e/48D2BCDC.6060809%40lsrfire.ath.cx
In-Reply-To: <20080918200120.GB8631@hashpling.org>

```
Charles Bailey schrieb:
> 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é

```

## Sverre Rabbelier, 2008-09-18 20:53

Subject: Re: [PATCH 1/1] Make git archive respect core.autocrlf when creating ...
Message-ID: <bd6139dc0809181353o26fb1ac2h7da63cf7da4bff1a@mail.gmail.com>
URL: https://gitlist.dev/e/bd6139dc0809181353o26fb1ac2h7da63cf7da4bff1a%40mail.gmail.com
In-Reply-To: <20080918202929.GA9948@hashpling.org>

```
On Thu, Sep 18, 2008 at 22:29, Charles Bailey <charles@hashpling.org> wrote:
> 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.

-- 
Cheers,

Sverre Rabbelier

```
