git p4 submit -- fails on 'could not determine file type'? - macos

Periodically, when I'm doing git p4 submit, I get a nasty error:
Could not determine file type for rails_project/public/favicon.ico
(result: '//mydepot/main/rails_project/public/favicon.ico#1 - add
default change (binary+l) *exclusive*')
In each case, it's some odd binary-type file that confuses the thing (like the favicon.ico above), or (most often) a graphic, like a PNG. And this kills the submit and leaves all the files that were opened before it in an opened state, but not yet submitted...
Resolving this ends up being a pain in the ass, where I end up having to use p4v to go in and manually submit half of what I was trying to submit via a new changelist, and then finish my submit (crossing my fingers that I don't hit another weird file and get stuck again).
(this is on git version 1.8.3.2 on a Mac with OS X Mountain Lion)
Has anyone come up with a way to make git p4 behave properly? Any ideas?

Looking at https://github.com/ermshiperete/git-p4/blob/master/git-p4 for "Could not determine file type for " the regex 're.match(".*\((.+)\)\r?$", result)' isn't matching against '//mydepot/main/rails_project/public/favicon.ico#1 - add
default change (binary+l) *exclusive*'.
I guess "*exclusive*" is new from perforce. or at least the git-p4 developer(s) haven't encountered it.
The easiest solution is probably to teach git-p4 about the new perforce syntax, and submit a patch.
EDIT:
Thinking about it - you probably don't want to use git-p4 for any files you (or your company) have decided should have exclusive locks, since git will break the exclusiveness of the locks.

Related

Restoring an Xcode commit that was never pushed to Github

This is a question that I posted, and then after much digging finally resolved myself. There is actually quite a bit on this subject both on this forum and elsewhere, but it usually requires some familiarity with Terminal. I am going to describe the problem I faced and then describe step-by-step in detail (at a beginner's level) how to resolve the issue in Terminal.
In short, I checked out a previously committed version of my app in Xcode, which - because it was a version from several weeks prior - did not contain my most recent commits. In other words, I had no access to any of the commits that contained my most recent work. They had all disappeared.
My commits and pushes had not stored in GitHub because presumably some time before this I had accidentally selected my main folder as the destination for my commits, rather than one of the two branches I created. So I had absolutely no access to my work. By all appearances I pretty much had to start from scratch.
After much hand wringing, teeth gnashing, and hours of scouring the webs, I finally uncovered the solution. But it takes a bit of understanding about Terminal to make it work. So after several more hours of learning Terminal, I finally successfully restored all of my work.
For any of you who are new to coding (as I am), and who have no experience with Terminal, I will provide detailed instructions on how to resolve this issue if you encounter it in the answer below.
Open Terminal to prompt to your Xcode project. The easiest way to do this is to find your project in Finder, which will have a .xcodeproj extension, and then right click it.
Select New Terminal at Folder.
At this point, a terminal window will pop up. From here, enter the following: git reflog
Press Enter
This will populate a list of all the commits stored in your Xcode project. Each commit is identified by an alphanumeric code (the one I restored was 1a7ea33, for example).
Note the alphanumeric code of the commit you wish to restore.
After this, enter the following: git checkout -b NewBranch 1a1a1a1 (where "NewBranch" is whatever name you decide to name your new branch, and "1a1a1a1" is your alphanumeric code from steps 5 and 6).
Press Enter.
That's it. Close Terminal and open your Xcode project as normal. You will notice the restored commit in the folder you just named in Terminal.
Hopefully no one will ever need this, but if by chance someone does I hope it helps.

git (windows) - find file that was saved locally but not committed/staged

I normally create new branches from master for different JIRA tasks and them merge them back into master with pull requests when the task is completed.
However, I'm using Rstudio and always have a local script open which acts a a rolling cookbook of tricks and tips to look back on. Basically its a library of my R knowledge.
Unfortunately I believe I've lost a couple of weeks work on this file as I think dropped any changes from the master branch, then created a new branch, created/edited a different file and merged back into master for a separate task.
I'm on Windows 10 and restore previous version doesn't seem to be available. The last restore point is a day after the last pull request I had merged. Im trying to find a way to find any other version of this file either in Git or older versions on my machine.
Whats the best way or tools to do this. I've lost some changes to an algorithm I'd been working on which successfully turned a 6 hour job into a 10 min job and I don't want to try and remember how I did it. I'm using visual studio for Git and I've got Git tortoise. According to tortoise There was a merge on 19/04 and nothing before 09/02 so I don't think Git ever staged or committed the changes I've lost that were all written between the 16/04 and 20/04.
EDIT
I think I've found it. Although its not in my Rstudio history in the UI (or the history file opened in notepad), when I use the search function in Rstudio's history it finds it?! Rstudio apparently has everything I've ever written and its timestamped too.
Still keeping this question open for future issues (although I've made this file local now to avoid this in the future). If anyone knows where the 'master' history file for Rstudio too thats of interest.
As mentioned in How to access the script/source history in RStudio?
RStudio's source panel is essentially a view to an Ace Editor
You have found the "searching history" which allows you to find back all past files/commands.

Can I force TortoiseGit to retry to unlink file while switching branches?

My primary development environment is within Windows but for Git, I try to mainly use the command line for doing most things and occasionally use TortoiseGit for others (such as viewing viewing logs or rebasing). Usually when switching branches, there are no problems when it's removing and restoring files. But certain programs lock these files (e.g., editing CSV files in Excel) which causes minor issues when switching branches.
If switching from the command prompt and a file is locked, it'll simply notify you that it was unable to unlink the file and ask you if you want to retry. This will give me a chance to close the program that has the lock and let it try again.
switching from command prompt
However, if I were to switch branches through TortoiseGit, it will have the error but will act as if the response was N and finish up leaving the files in their current state. It gets a little annoying as I have to go back and manually revert the files. I'd rather have it wait and ask me to try again, like it usually does with other actions.
switching from TortoiseGit
Is there any way I can force TortoiseGit to halt and ask me to retry unlinking the file when switching branches? Or is this just not a feature of TortoiseGit?
Up to TortoiseGit 2.2.3 the yes/no question wrapper (GIT_ASK_YESNO) was not implemented. Starting with 2.2.4 this will be supported, however, I don't know why after an "error" success is reported by git.exe.

Undoing a single-file Git Checkout

So, I am working on a project with XCode. Happily, I found out that it keeps an Git repository within every project. So, after a mistake on a code, i just used
git checkout aux.c
to move back from theses mistakes. Unfortunately, as i just found out, Xcode does not auto-commit, so, I ended up with a blank file.
I didn't commited anything after this, but still can't figure out how to undo this checkout.
Sorry, you can't. :-( You're going to have to replace the file some other way.
There are two places where git tracks your files - commits, and the index/staging area. Since there was no commit, and you checked the version of the file out of the staging area, there's no other place it would be.
Do run git status just in case, to make sure it doesn't still show staged changes to that file.
Any chance you had it open in an editor still and could undo the changes to the file that git checkout made? Some editors like Textmate and SublimeText will allow that; others don't.
If the file has never been committed to the repository then unfortunately you are out of luck.
From the sounds of it, you simply have an empty git repository, which will mean your file has been lost and something Versions (which comes with Lion) or Time Machine may be your best bet at recovering from your mistake.
To confirm if anything has been committed to the repository, use git log. If you get an empty response then you're out of luck on the git front.
Unfortunately, this probably this isn't the answer you were looking for.
In fact, undoing a first commit on git is impossible. So, if you are running Xcode, commit manually frequently.
But, there is another way.
If you are running OS X 10.7 Lion or latter (not sure about Snow Leopard), you can try to use the versions feature from OS X to recover any file. Too late for me, but it should work
Best way to recover if your uncommitted changes would be to go to (Left Pane) Source Control Navigator -> Stashed Changes -> Look for a file which dated/timed earlier than your commit which you would like to reverse and click to apply stash changes to the file. That would bring back all the unsaved files back.

SVN diff flagging all lines of code as new when PC programmer updates file recently committed by Mac Programmer

Here's the scenario I'm currently running into:
Programmer A (Using a Mac Version of Dreamweaver) edits file client.php and commits that file to the production branch of Project Foo's repository
Programmer B (Using a Windows Version of Dreamweaver) edits file client.php to fix a bug in the that file. He then does a cp clientInfo.php ../prod-branch/clientInfo.php to take that bug-fix from his working copy to the production branch.
Programmer B then does an svn diff ../prod-branch/clientInfo.php to see what svn says his changes were only to discover that svn says he's changed every line in the file!
Now, this is what I believe is happening:
When the file gets edited by Mac, Dreamweaver on Mac replaces all the Windows newline characters with Mac newline characters so that it's readable in Dreamweaver. In short, Dreamweaver has altered every line in the file. Now, once the commit is done, svn sees that every line of the file has changed and marks this fact down. When the windows programmer makes a change and the newline characters get changed again, svn thinks that, again, every line has changed.
My question is this: How can we prevent this from happening? I know there's no way to undo the damage that's already been done, but I want to prevent this from happening in the future.
You need to use the "svn:eol-style" property on all text files. Usually setting it to "native" will suffice
Dreamweaver has an option to set which line break type it uses. Edit (on Mac: Dreamweaver ) -> Preferences, Code Format, Line break type.
Get your users to have the same setting, and things should play a little better together. It would be better, of course, if you can set your source control to ignore line break differences.
svn:eol-style is a property that can be set centrally in the repository and should sort out your problem.
Check out the chapter on New Line Sequences in the Subversion book.
The solution to this problem is the svn:eol-style property. When this property is set to a valid value, Subversion uses it to determine what special processing to perform on the file so that the file's line ending style isn't flip-flopping with every commit that comes from a different operating system. The valid values are:

Resources