I'm new to linux and bash so I'm sorry if my question will be stupid, but I have problem with creating and applying patch file.
Lets say I have two directories original/ and new/ and in the original directory are few files like 4 or 5 that are either completly missing in new/ or are changed and some of them are in some subdirectories.
According to some tutorial I shoud use diff -rubN original/ new/ > patch.diff but other tutorials state the opposite that i sohold use diff -rubN new/ original/ > patch.diff
Anyway if I use the first one and then run patch -t -p0 < patch.diff strange thing happens, I get results "patching file original/subfolder/filename" for all files and then the original/ folder dissapear, the new/ folder is still empty and I have to run the patch command again. When I do I get messages "The next patch would delete the file new/subfolder/filename, which does not exist!" - after this there are files in new/ folder, which is fine, but I dont know:
why was the original/ folder deleted
why I have to run the patch command twice to get the files to the new/ folder
why the patch gives me message that the file doesn not exist when they do?
Edit: if it is not clear from the text, I am trying to transfer changes that are in the files in the original/ folder to the new/ folder. Seems that the second diff (diff -rubN new/ original/ > patch.diff) is working for this case and for one file only as it should... but as soon as the diff is for more than one file, for example if I add new file to the original/ folder, that doesnt exist in new/ folder, the patch ends with those strange way, deleting the file that is not in the new/ folder and print message that "The next patch would create the file ../path to the original file/.. which already exists!" and "patching file ../path to the original file"
Also one new observation, after first patch commend only files that dont exist in the new/ folder seems to be deleetd from the original/ folder
Edit2: Ok, just find out that if i use cd new/; patch -p1 < ../patch.diff the patch ends OK and the original/ folder is not deleted. I just didnt get why because to me ot seems to be same code -> p0 from directory where /original and /new folders are OR p1 from /new directory .... I cant see the difference
Related
I have a folder that regularly gets updated. This folder is a part of a TFS workspace. I need to commit all those changes to the workspace once they occur (add what isn't there, delete what was removed and update what was changed).
Currently, I have a script that runs tf vc folderdiff command on the folder and its server counterpart, parses out the output to get three lists - files that need to be added, deleted and updated. It then manually adds, deletes and updates those files by invoking tf add/delete/checkout on batches of files (trying to add/delete/checkout in one go can cause an error if there are too many files in the list).
There has to be some better way. Is there some kind of tf command where I can tell it, look at this local folder, look at the server folder that is mapped to it and make the server folder look exactly the same? Bonus points if I can specify some kind of filter to exclude certain paths or file names/extensions.
Apparently there exists a tf reconcile command. You can learn more about the syntax here: https://learn.microsoft.com/en-us/azure/devops/repos/tfvc/reconcile-command
Off the top of my head, the following command should do what I want:
tf reconcile [path to folder] /promote /adds /deletes /recursive /noprompt
There is also /exclude that can be used to filter unwanted files, so I get the bonus points too.
Of course I had to stumble upon it right after asking a question...
I try make a script witch go through a directory and for each file in the directory it will make a zip archive copy the archive somewhere else and then extract the archive. In the end, the whole directory i copy from has to equal to the new directory somewhere else but in files were copied has archive.
i had a problem with going through all files in the directory because it has a lot of sub directories so i could not go through all of them with a simple for loop.
My plan was to copy first all the directories and sub directories "xcopy /t /e" and then go through the files and archive copy and extract each one of them individually but as i said earlier i could not do it.
If someone can help me and show me how to to go through files like that or how to accomplish my mission, it will be perfect.
Thank you.
You could use recursion for that. Both zip -r or rsync could do the job in a very simple way. You do not have to loop.
I ask a few questions here and every time I am very pleased with the answers, so here we go again.
I have three folders inside the folders the files have the same names except for the file structure:
1 folder with .zip
1 folder with .7zip
1 folder with different folders
I really would like to get all the matching files from the .zip.
So .zip is leading and I am looking for a batch file that will copy the files from the other folders.
I really hope this makes any sense :) English isn’t my first language.
Use the find command.
find . -regex '.*\.zip' -exec cp {} target_dir \;
I am renaming a series of .js files using Refactor -> Rename.
They all work except when I rename a file to an all-lowercase name (i.e. rename Calendar.js to calendar.js). I get this error:
move C:/Users/JohnDeer/workspace/MyApp/WebContent/scripts/ui/Calendar.js C:/Users/JohnDeer/workspace/MyApp/WebContent/scripts/ui/calendar.js
Path is not a working copy directory
svn: Path 'C:\Users\JohnDeer\workspace\MyApp\WebContent\scripts\ui\calendar.js' is not a directory
I checked the ui folder and there is a .svn folder in it.
I think the problem is that file names are not case sensitive in Windows. So the lowercase name registers as the original name and maybe when the source file is the same as the destination, the latter is understood as a directory.
As a workaround you can try to use a temporary intermediate file:
rename Calendar.js to tmp.js
then rename tmp.js to calendar.js
Another possibility is to rename the file in the repository by hand (this can be done using Eclipse's Repository Browsing View as well as from the command line) and then update the project.
What I did:
renamed a file
tried to commit
cvs fails with error message
file should be removed and is still there (or back again)
What is the problem and how do I solve it so that I can commit?
Additional information:
I'm using Eclipse with the CVS plugin.
doing an ls in the directory where the file was shows that it is not there
All the other Google hits for this problem (including this question) seem to be asking what to do when a file has been removed with cvs, and then restored outside of cvs' scope. My problem is different: I just need to rename a file.
It means that the file was flagged for deletion by CVS but then appeared again. Renaming for CVS is just a deletion of the file with old name and adding the file with new name. The file must be appeared again with its old name.
You can do 2 things:
1) If you don't need this file then just delete it. (Use cvs -n update command to find its name.) Then you will be able to commit.
1) if you need this file to stay, go to the .CVS subfolder of the folder where the file is located and edit Entries file. Find a line with your file and delete it. Then rename you file (give it a temporary name), call cvs update, rename your file back overriding the new one appeared after cvs update.