3

I have a strange file without a file extension that's supposedly an archive of the contents of a git repository. According to file (1), it's an "X1 archive":

$ file my_git_repo 
my_git_repo: X1 archive data

However, I can't figure out any way to extract or view the contents of this file. I've tried:

  • tar
  • unzip
  • bzip2
  • xz
  • lzip
  • lzma
  • lzop
  • gzip
  • uncompress

But none of these tools recognize my file. I've also tried looking on Wikipedia and the Arch Wiki for help, but neither of these pages mention "X1". I also tried Googling variations of "X1 archive" or "extract X1 file", but mainly I got results for products or services named "X1", and nothing that seemed related to a file format called "X1". Finally, I tried taking a look at the file with tools like strings, and the file does contain filenames of the files I expect to be in my git repository as well as snippets from files within that repository, so I don't think this file is just random data or anything like that.

What kind of file do I have and how can I view its contents?

  • 1
    The information X1 archive is coming from libmagic. To get a better understanding of the file, can you provide the first bytes of the files via hexdump -n 64 -C my_git_repo? It might give a better insight. – U880D Apr 19 '18 at 19:56
  • @U880D that's essentially what I did. See the answer I posted. – jayhendren Apr 19 '18 at 20:01
4

Okay, I got this one figured out.

I noticed that the first line of the file contains a curious string:

% head -n 1 my_git_repo | strings
X11 forwarding request failed on channel 0

That string looks familiar. My default SSH config tries to forward X11 connections, but when it fails to do so -- such as when running git operations to git servers over ssh -- that string is printed on stderr:

$ git archive --remote=ssh://git@my.git.server/my_git_repo.git master > my_git_repo.tar
X11 forwarding request failed on channel 0

I'm guessing that the library that created the git archive captured both stdout and stderr instead of just stdout, which would explain how the first line of that file came to be.

So if I remove the first line of that file, I get a much more reasonable output from file (1):

$ tail -n +2 my_git_repo > my_git_repo.edit
$ file my_git_repo.edit 
my_git_repo.edit: Zip archive data, at least v1.0 to extract

And if I rename the file to my_git_repo.zip and try to view the contents of the file with unzip -l, I find that it contains the files I expect, and when I extract the archive with unzip, I get the files I want.

I'm not sure where libmagic got the idea that this file was an "X1 archive" to begin with, but I'm guessing it has to do with "X1" being the first two characters of the corrupted file.

  • Many files use the first two or four characters of the file to describe the type of the file as "magic number" (e.g. MZ for DOS executables, #! for shell scripts), so possibly file saw that both were ASCII, and reported that as a guess after all other detection methods failed. – dirkt Apr 20 '18 at 6:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.