Why does `git checkout` produce the error `Invalid argument` when hash of the tree is used -


i'm trying create git tree , check out without using high-level commands , commit objects. initialized git , create 2 blobs:

$ git init  $ echo ‘f1’ | git hash-object -w --stdin 8e1e71d5ce34c01b6fe83bc5051545f2918c8c2b  $ echo ‘f2’ | git hash-object -w --stdin 9de77c18733ab8009a956c25e28c85fe203a17d7 

now i'm creating tree using mktree:

$ echo -e      "100644 blob 8e1e71d5ce34c01b6fe83bc5051545f2918c8c2b\tf1.txt"      "100644 blob 9de77c18733ab8009a956c25e28c85fe203a17d7\tf2.txt"      | git mktree bf9571850c4570cd36ffa426343b81364a855911 

which correctly returns me git tree hash. want check out. according this answer can this:

$ git checkout bf9571850c4570cd36ffa426343b81364a855911 . 

but produces error:

error: unable create file f1.txt 100644 blob 9de77c18733ab8009a956c25e28c85fe203a17d7        f2.txt (invalid argument) 

can help?

there's wonky in instructions, because if retype:

$ echo 'f1' | git hash-object -w --stdin 

i same hash:

8e1e71d5ce34c01b6fe83bc5051545f2918c8c2b 

but if try cut , paste them, different. because (i'm not sure what) has damaged single quotes: yours unicode u+2018 characters, or left single quotation mark.

anyway, result not quite sure third echo command, if assume it's undamaged, it's sending:

100644 blob 8e1e71d5ce34c01b6fe83bc5051545f2918c8c2b\tf1.txt 100644 blob 9de77c18733ab8009a956c25e28c85fe203a17d7\tf2.txt 

(where each \t represents literal tab character) git mktree, make tree one entry. trying gives me:

$ printf "100644 blob 8e1e71d5ce34c01b6fe83bc5051545f2918c8c2b\tf1.txt 100644 blob 9de77c18733ab8009a956c25e28c85fe203a17d7\tf2.txt\n" | git mktree bf9571850c4570cd36ffa426343b81364a855911 

which has same tree-hash, and:

$ git cat-file -p bf9571850 100644 blob 8e1e71d5ce34c01b6fe83bc5051545f2918c8c2b    "f1.txt 100644 blob 9de77c18733ab8009a956c25e28c85fe203a17d7\tf2.txt" 

(i've left raw tab in stackoverflow input, little bit tricky works cut-and-paste on mac).

checking out tree current directory attempt create file named f1.txt 100644 blob 9de77c18733ab8009a956c25e28c85fe203a17d7\tf2.txt (with embedded tab in name) 1 should expect. presumably host os (windows?) refuses such file names.

presumably, wanted print two lines git mktree, 1 each f1 , f2 files. printf command better way that:

$ printf '%s %s %s\t%s\n' \ > 100644 blob 8e1e71d5ce34c01b6fe83bc5051545f2918c8c2b f1.txt \ > 100644 blob 9de77c18733ab8009a956c25e28c85fe203a17d7 f2.txt | > git mktree 97da1d249d1b56762add1fb35096a46544416c7f $ git checkout 97da1 -- . $ ls f1.txt  f2.txt 

Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -