From 9f814c11448246b71633e83fb2802716fb1476b4 Mon Sep 17 00:00:00 2001 From: rick olson Date: Wed, 27 Sep 2017 11:42:44 -0600 Subject: [PATCH 1/2] only copy req headers if there are git-configured extra headers --- lfsapi/client.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lfsapi/client.go b/lfsapi/client.go index 641a255c7e..6490640eba 100644 --- a/lfsapi/client.go +++ b/lfsapi/client.go @@ -97,12 +97,17 @@ func (c *Client) Close() error { } func (c *Client) extraHeadersFor(req *http.Request) http.Header { + extraHeaders := c.extraHeaders(req.URL) + if len(extraHeaders) == 0 { + return req.Header + } + copy := make(http.Header, len(req.Header)) for k, vs := range req.Header { copy[k] = vs } - for k, vs := range c.extraHeaders(req.URL) { + for k, vs := range extraHeaders { for _, v := range vs { copy[k] = append(copy[k], v) } From 7158e3bb633176a39743f0efff8e53abc100b6f5 Mon Sep 17 00:00:00 2001 From: rick olson Date: Tue, 3 Oct 2017 10:48:18 -0600 Subject: [PATCH 2/2] add files to index with path relative to current dir --- commands/pull.go | 6 +++--- test/test-pull.sh | 45 ++++++++++++++++++++++++++++++++++++++------- test/testhelpers.sh | 9 ++++++++- 3 files changed, 49 insertions(+), 11 deletions(-) diff --git a/commands/pull.go b/commands/pull.go index a825af5f13..c9acbc0da6 100644 --- a/commands/pull.go +++ b/commands/pull.go @@ -38,8 +38,10 @@ type singleCheckout struct { } func (c *singleCheckout) Run(p *lfs.WrappedPointer) { + cwdfilepath := c.pathConverter.Convert(p.Name) + // Check the content - either missing or still this pointer (not exist is ok) - filepointer, err := lfs.DecodePointerFromFile(p.Name) + filepointer, err := lfs.DecodePointerFromFile(cwdfilepath) if err != nil && !os.IsNotExist(err) { if errors.IsNotAPointerError(err) { // File has non-pointer content, leave it alone @@ -56,8 +58,6 @@ func (c *singleCheckout) Run(p *lfs.WrappedPointer) { return } - cwdfilepath := c.pathConverter.Convert(p.Name) - err = lfs.PointerSmudgeToFile(cwdfilepath, p.Pointer, false, c.manifest, nil) if err != nil { if errors.IsDownloadDeclinedError(err) { diff --git a/test/test-pull.sh b/test/test-pull.sh index b59c7d9bb2..cb9b6e7ab4 100755 --- a/test/test-pull.sh +++ b/test/test-pull.sh @@ -19,33 +19,42 @@ begin_test "pull" contents_oid=$(calc_oid "$contents") contents2="A" contents2_oid=$(calc_oid "$contents2") + contents3="dir" + contents3_oid=$(calc_oid "$contents3") + mkdir dir + echo "*.log" > .gitignore printf "$contents" > a.dat printf "$contents2" > á.dat - git add a.dat á.dat .gitattributes + printf "$contents3" > dir/dir.dat + git add . git commit -m "add files" 2>&1 | tee commit.log grep "master (root-commit)" commit.log - grep "3 files changed" commit.log + grep "5 files changed" commit.log grep "create mode 100644 a.dat" commit.log grep "create mode 100644 .gitattributes" commit.log ls -al [ "a" = "$(cat a.dat)" ] [ "A" = "$(cat "á.dat")" ] + [ "dir" = "$(cat "dir/dir.dat")" ] assert_pointer "master" "a.dat" "$contents_oid" 1 assert_pointer "master" "á.dat" "$contents2_oid" 1 + assert_pointer "master" "dir/dir.dat" "$contents3_oid" 3 refute_server_object "$reponame" "$contents_oid" refute_server_object "$reponame" "$contents2_oid" + refute_server_object "$reponame" "$contents33oid" echo "initial push" git push origin master 2>&1 | tee push.log - grep "(2 of 2 files)" push.log + grep "(3 of 3 files)" push.log grep "master -> master" push.log assert_server_object "$reponame" "$contents_oid" assert_server_object "$reponame" "$contents2_oid" + assert_server_object "$reponame" "$contents3_oid" # change to the clone's working directory cd ../clone @@ -58,11 +67,12 @@ begin_test "pull" assert_local_object "$contents_oid" 1 assert_local_object "$contents2_oid" 1 + assert_clean_status echo "lfs pull" - rm a.dat á.dat + rm -r a.dat á.dat dir # removing files makes the status dirty rm -rf .git/lfs/objects - git lfs pull 2>&1 | grep "(2 of 2 files)" + git lfs pull 2>&1 | grep "(3 of 3 files)" ls -al [ "a" = "$(cat a.dat)" ] [ "A" = "$(cat "á.dat")" ] @@ -70,9 +80,9 @@ begin_test "pull" assert_local_object "$contents2_oid" 1 echo "lfs pull with remote" - rm a.dat á.dat + rm -r a.dat á.dat dir rm -rf .git/lfs/objects - git lfs pull origin 2>&1 | grep "(2 of 2 files)" + git lfs pull origin 2>&1 | grep "(3 of 3 files)" [ "a" = "$(cat a.dat)" ] [ "A" = "$(cat "á.dat")" ] assert_local_object "$contents_oid" 1 @@ -105,6 +115,27 @@ begin_test "pull" rm -rf .git/lfs/objects git lfs pull --exclude="a*" refute_local_object "$contents_oid" + + echo "resetting to test status" + git reset --hard + assert_clean_status + + echo "lfs pull clean status" + git lfs pull + assert_clean_status + + echo "lfs pull with -I" + git lfs pull -I "*.dat" + assert_clean_status + + echo "lfs pull in subdir" + cd dir + git lfs pull + assert_clean_status + + echo "lfs pull in subdir with -I" + git lfs pull -I "*.dat" + assert_clean_status ) end_test diff --git a/test/testhelpers.sh b/test/testhelpers.sh index 531d934bd5..c7fe7660a3 100644 --- a/test/testhelpers.sh +++ b/test/testhelpers.sh @@ -238,6 +238,14 @@ assert_hooks() { [ -x "$git_root/hooks/pre-push" ] } +assert_clean_status() { + status="$(git status)" + echo "$status" | grep "working tree clean" || { + echo $status + git lfs status + } +} + # pointer returns a string Git LFS pointer file. # # $ pointer abc-some-oid 123 @@ -340,7 +348,6 @@ clone_repo_url() { echo "$out" } - # clone_repo_ssl clones a repository from the test Git server to the subdirectory # $dir under $TRASHDIR, using the SSL endpoint. # setup_remote_repo() needs to be run first. Output is written to clone_ssl.log.