XAML files are recognized as binary by git

All XAML files in my project are recognized as binary by git. Hence I’m unable to use diff or resolve conflicts when merging xaml files.

This is the response I get when I rebase:

First, rewinding head to replay your work on top of it...
Applying: init apps
warning: Cannot merge binary files: Main.xaml (HEAD vs. init apps)
warning: Cannot merge binary files: Framework/GetTransactionData.xaml (HEAD vs. init apps)
Using index info to reconstruct a base tree...
M       Framework/GetTransactionData.xaml
M       Main.xaml
Falling back to patching base and 3-way merge...
Auto-merging Main.xaml
CONFLICT (content): Merge conflict in Main.xaml
Auto-merging Framework/GetTransactionData.xaml
CONFLICT (content): Merge conflict in Framework/GetTransactionData.xaml
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch' to see the failed patch
Patch failed at 0001 init apps
Resolve all conflicts manually, mark them as resolved with
"git add/rm <conflicted_files>", then run "git rebase --continue".
You can instead skip this commit: run "git rebase --skip".
To abort and get back to the state before "git rebase", run "git rebase --abort".

This is the attributes of xaml file when I run git check-attr --all Main.XAML
Main.xaml: binary: set
Main.xaml: diff: unset
Main.xaml: merge: unset
Main.xaml: text: unset

I tried adding the below text to .gitattributes
.xaml diff
yet the attributes of .xaml is treated as binary

@Karthik_S Try This

@indra Thanks Indra, your suggestions worked out.

I copied the XAML files to new directory and initialized the local repo. The diff worked fine then. I googled a bit and found the cause of the bug.

When a project is created in UiPath and the repository is initialized, the XAML and JSON files are recognized as binary due to the fact that git couldn’t find the newline character in those file types. Refer this stack overflow post to know why why git ignores the newline character(CRLF).

To counter this, .git/info/attributes file must be edited to remove
*.json binary
*.xaml binary
This makes the git to treat XAML and JSON files as text files.

4 Likes

Hi @Karthik_S

Do you know how the .git/info/attributes file came to be? I was shared a test project for these symptoms and attempted to compare the files as text using the .gitattributes with no luck and after digging into the documentation I realized .git/info/attributes takes precedence.

When deciding what attributes are assigned to a path, Git consults $GIT_DIR/info/attributes file (which has the highest precedence), .gitattributes file in the same directory as the path in question, and its parent directories up to the toplevel of the work tree (the further the directory that contains .gitattributes is from the path in question, the lower its precedence). Finally global and system-wide files are considered (they have the lowest precedence).

I attempted to replicate it

  1. Created new UiPath Project in Studio 2019.10.4
  2. Initialized the Git repository with Git CLI git init
  3. Committed the files
  4. Made changes to a xaml
  5. Checked Diff

The diff treated it as text as the .git/info/attributes did not exist. So it is unclear to me what sequence of events led to the attributes file being created with .xaml & .json set to binary.

I also noticed Git diff displaying ^M and updated the git config to have core.whitespace cr-at-eol

Cheers,
Tim

Created the following User Voice feedback. Seems to create/update the attributes file eachtime the workspace is opened.

@Karthik_S thank you. That helped us solve merge conflicts properly.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.