Find the last commit to have changed a file - windows

Question
Using the svn command line, I would like to find the last commit that touched a file. Here it is in pseudo-code:
svn log -v --search my-file.txt --first-match
What I have tried:
svn log -v --search my-file.txt -l 1
Unfortunately, this only searches the most recent commit. It doesn't return the first match.
svn log my-file.txt -v -l 1
Subversion complains that:
svn: E155010: The node 'C:\Users\my.user\Documents\SubversionSvn\MyDir\my-file.txt' was not found.
svn log svn://my.server.com/svn/path/to/my-file.txt
Svn complains that:
svn: E160013: File not found: revision 427, path '/svn/path/to/my-file.txt'

Just get the log of the file and limit it to the first (most recent) entry:
svn log my-file.txt -v -l 1
If the file was in your repository but was deleted, you'll need to pass a peg revision so SVN knows what file you're asking about:
svn log my-file.txt#3511 -v -l 1
Here, the peg revision is 3511 which is the last revision where the file existed before it was deleted from the repository. However you've already answered your question once you've found this number.
If the file was never in the repository (it isn't now, based on your errors), then this isn't a question that SVN can answer for you.

I use GUI , go to file on your comp, right click on file , TortoiseSVN > Diff with previous version
Link for command line

Related

Git for Windows "No tags file" Response from "git diff" Command

Git version: 2.14.2.2
Whenever I run git diff on a repository I am greeted with the response No tags file. I have tried running the command on multiple repositories, multiple consoles (Cmd, PowerShell, MINGW64, Visual Studio Command Prompt) and all have the same response.
Strangely, the git log command also fails. Many other commands work, however, such as git status, git pull, etc. It seems to be only log and diff.
I have uninstalled Git entirely and reinstalled. Restarted my system. Tried referencing the git.exe directly (which yields the exact same response). Nothing is working and I have not seen this error anywhere else. I compared my user configs with those of a colleague and they are identical.
Some portion of the command executes properly, because if I supply two commit hashes, and I intentionally break one, the response I receive is:
It seems like another program may be hijacking the git diff command. I believe this because I'm not sure "No tags file" is even a possible Git response. Not sure what else it would be.
To make things even more confusing- my ultimate goal is to run the git diff within the context of an msbuild and it DOES EXECUTE CORRECTLY. Now, I could be satisfied with this, but I need to modify the diff command slightly, and running a full build each time is not productive, nor easy to troubleshoot. There is a task within the build script that runs an Exec command and it has no issues performing the diff. I'm also able to execute a Diff Against Current within SourceTree, which to the best of my knowledge, runs a git diff behind the scenes.
Any help would be very much appreciated.
:: Edits ::
Various commands:
git diff HEAD~1 HEAD
git diff master~1 master
git diff <commit-hash-1> <commit-hash-2>
git log HEAD~1..HEAD
git log master~1..master
git log <commit-hash-1>..<commit-hash-2>
Output:
Every one of the commands above returns the same No tags file response, in all of my repos.
Cat Head:
cd .git
cat HEAD
ls -R refs
Output:
New Repo:
mkdir testrepo
cd testrepo
git init
echo "file1" > file1.txt
git add .
git commit -m "initial commit of file1.txt"
echo "Hi there!" > file2.txt
git add .
git commit -m "added file2.txt"
git log
git diff HEAD~1 HEAD
Output:
git config -e:
git config --global -e:
::Edits 2::
I uninstalled all of my diffing/source control tools (SourceTree, Git, SVN, WinMerge, KDiff). Installed the portable version of Git. Opened CMD to a repo, put in full path to the git.exe portable and it still returned the No tags file response.
I also reviewed all of my path variables for: git, vim, ming, mintty and anything else that seemed suspect, but didn't find any.
I have restarted after performing all steps, and yet the problem persists.
::Edits 3::
I have a different user on my laptop, switched to that user and the git diff works properly, so clearly there is something with my main user that is conflicting. Will continue to look into my User directory for issues.
Here are the steps I'd take in this situation:
Try the following and check the response:
git diff HEAD~1 HEAD
git diff master~1 master
git diff <commit-hash-1> <commit-hash-2>
Try the same with log:
git log HEAD~1..HEAD
git log master~1..master
git log <commit-hash-1>..<commit-hash-2>
I'm actually guessing that your refs are messed up, which means that the direct hashes might work, but the HEAD and/or master one may not.
Look into the .git/refs folder
From the main repo folder:
cd .git
cat HEAD
ls -R refs
Hopefully, HEAD is pointing to a branch, and if master is checked out, cat HEAD output should look like:
ref: refs/heads/master
Then, the ls -R refs, should show a heads folder, with files for each of your local branches (i.e. master and possibly others). You also likely have refs/remotes and refs/tags directories.
If any of these things are radically different or missing, that could be your issue...
Since you have reinstalled git, create a brand new repo and try the same commands:
mkdir testrepo
cd testrepo
git init
echo "file1" > file1.txt
git add .
git commit -m "initial commit of file1.txt"
echo "Hi there!" > file2.txt
git add .
git commit -m "added file2.txt"
git log
git diff HEAD~1 HEAD
If this last one works, then git is likely working okay, but some tool you have is messing things up.
Post your config from git config -e and git config --global -e - maybe we can see something?
When googling for the "No tags file" message, the first results I get all talk about vi.
I do not understand why git would try to execute vi when running git diff or git log, could it be that your system is configured to use vi as a pager ?
# some possible places which could influence that :
echo $PAGER
echo $GIT_PAGER
git config --get core.pager
When digging in the documentation for less, I found that less can use a ctags file, to spot "the file that contains this tag".
So you can also look at the list of variables that influence the behavior of less :
# from bash :
# env will list all the defined environment variables
env
# the ones that impact 'less' should contain "LESS" in their names :
env | grep LESS

How to get the last SVN revision number from a given date?

I need to obtain the first revision number after given date?
For example, I need to know which is the first SVN revision number for the project Apache Hadoop after 2011-11-29.
I tried the command
svn log -r {2011-11-29} http://svn.apache.org/repos/asf/hadoop/common/trunk/
but in this case, there are no commit on 2011-11-29.
How can I get the first commit of 2011-11-29 or if not exist, after this date?
And finally, how can I only get the revision date from the SVN log?
Revisions in date period
Try
svn log -r {2011-11-01}:{2011-11-30} ## revision between dates
or
svn log -r {2011-11-01}:Head ## revisions from 2011-11-01 to head
or
svn log -r {2011-11-01}:Head -l5 ## Top 5 revisions from 2011-11-01 to head
http://svnbook.red-bean.com/en/1.8/svn.ref.svn.html#svn.ref.svn.sw.revision
Get revision date from log
Try
svn.exe log --xml
And parse <logentry><date> tags with bash

How to fix subversion <<!>> and <<?>> status automatically?

I use svn to sync my text files or any important notes which i place in my mac filesystem to my server. So, when i modify the file i use Sublime to add or delete files which are under svn-control and thus gets unsync with svn commands.
How do i fix it other than running the svn commands? I know i should use svn commands to rename or add or remove the files, but how do i do without using svn command? In Windows, i believe tortise SVN make note of those changes and we just need to commit but is there any software for mac which does the samething?
$ svn status
? MySql/MySQL_Start_On_Different_OS
! OS/Software/Nginx_Atmosphere.txt
! OS/Software/Nginx_Caching.txt
! OS/Software/Nginx_RpmInstallation.txt
! OS/Software/Nginx_Windows.txt
Again, i know i can fix the above status by doing svn add or svn remove <filename>. Atleast was there any command or script that convert ! to remove and ? to add?
To the first part of your question: Since you mention TortoiseSVN, I think you are looking for a graphical user interface to svn that helps you with adding/deleting files. Here is a short overview of available clients for OS X. I have personally used Cornerstone and was content enough with it, although there are certainly cheaper options that sound like they fulfil your requirements just as well.
As to the part where you are looking for a scripting solution: Use
svn st | grep "^?" | awk '{print $2}' | xargs svn add
to add all files marked as unknown by svn (i.e. ?). Use
svn st | grep '^!' | awk '{print $2}' | xargs svn rm
to remove all files that were already marked as deleted by hand (e.g. !). Then commit to svn with
svn ci -m "Your commit message goes here."

Xcode and Git Source Control : "The working copy XXXXX failed to commit files"

I know this may be an ultra-newbie question, but - although I've been coding for like 18 years - it's been only a few days that I've been using Source Control for my project and I feel quite lost.
I have set up Git properly and, from time to time, I'm commiting the changes.
(File -> Source Control -> Commit)
However :
Whenever I try to delete a file (that initially existed) and then commit the changes, I'm getting an error like this :
The working copy "MY_COPY_NAME" failed to commit files
fatal: could not switch to "/the/path/of/the/file/i/just/deleted": no
such file or directory
What's going on?
What should I do in order to commit the changes even after a file has been deleted?
you should run
git add -u your_file
the -u means you want to update the file you already added. Another possibility is
git rm your_file
And it's likely you get an error if Git does not find an inexisting
To fix above error you should use below lines of code:
Open the command line [Terminal] and enter the following two commands:
xcrun git config --global user.email your#Email.com
xcrun git config --global user.name "Enter Your Name"

Can we select what version to be checked out from CVS

I have updated cvs a few times and want to get one of the older versions, is it possible to get different versions of the same file? Or should it be only the latest checked in version?
Switch to a certain revision number: cvs update -r 1.42 myfile
Switch to a certain tag: cvs update -r mytag
Switch to a certain date: cvs update -D 'last friday 12:00 PST'
If you haven't already checked out some version, you can pass -r or -D directly to cvs checkout.
These all switch your working copy to the revision or date you specified (this is called a “sticky tag”). To go back to the head revision, issue cvs update -A.
You can also retrieve a specific revision into a different file with the -p option: cvs update -p -r 1.42 myfile >myfile-1.42. This doesn't touch your working copy of myfile.
Yes - in the lingo of CVS it sounds like you have committed several versions (to the repository) and now you want to get one of the previous revs back... so you will be updating your sandbox. If it's a particularly interesting rev, you might want to TAG it so you can find it again without having to use the rev number.
In either case you might run a cvs command like so:
cvs update -r 1.14 foo.java
cvs update -r spiffy_tag foo.java
But know that if you run either of those, you will have a "sticky tag" in your local copy and cannot commit back from there. (Run "cvs status foo.java" to see the sticky)... so if you want to work on that rev and tune it up, you might want to create a branch first... then if you run:
cvs update -r my-branch foo.java
you will be able to commit changes back to the repo.

Resources