Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have got an account on a server at my university. I want to share a program code with another student. I thought I should put it on my github account. Unfortunately, I cannot because the code is part of a contest.

I decided to make a Makefile so that we could easily upload and download files. After a while I finally understood that is not enough. Then I implemented patch system so that only changes are stored. There should be no problem with small simultaneous changes.

The Makefile almost do the job but there are some details I can't solve. The Makefile

all: download
PHONY: all, download, upload, getFiles

.ONESHELL:
getFiles:
    rm ../.tmp -r
    mkdir ../.tmp
    @(ssh $(user)@host "tar c *") | tar xv -C ../.tmp 

download: getFiles
    @diff -u ../.tmp . | patch -p1
    rm ../.tmp -r

upload: getFiles
    @diff -uN ../.tmp . | (ssh $(user)@host "patch -p1")
    rm ../.tmp -r

I removed all data from host. Now I want to upload but tar stops program because there are no files to download in order to find out changes.

Moreover, I cannot make my mind in the case: should I use -N in diff or not? Simply, I do not know how it behaves when I delete a file.

There is another problem: when something goes wrong the .tmp directory is not removed. The directory should be removed every time. Next action always download current "repository" status.

I fully recognize the fact it is not a repository, but I cannot set up a server program on the remote host and I think the Makefile will do the job for me.

Any hints will be appreciated.

share|improve this question
    
Have you considered sending patches by email? –  Daniel Beck Dec 9 '11 at 19:27
    
No. I think using makefile is much more convenient. –  lord.didger Dec 9 '11 at 19:50
    
@lord.didger: Daniel meant "have you considered using git-format-patch / git-send-mail" ... and that in combination with commit-hooks. –  akira Dec 9 '11 at 19:54
1  
Why not using a Git repository over SSH? –  cYrus Dec 9 '11 at 19:57
1  
git over email? that would be the best option. Unfortunately, I have very basic knowledge of git. Getting know how to fire git over email will take some time. @cYrus: Git over ssh? what you mean? –  lord.didger Dec 9 '11 at 20:02
show 3 more comments

1 Answer

I have finally managed to fix the Makefile. I think it works fine. Obviously it is not a professional repository but it does the job. The Makefile:

-include name

all: download
PHONY: all, download, upload, getFiles

DIFFFLAGS = -uNr

.ONESHELL:
getFiles:
    rm .tmp -r
    mkdir .tmp
    (ssh $(user)@$(HOST) "tar c ") | tar xv -C .tmp

download: getFiles
        diff $(DIFFFLAGS) program .tmp/roboty | patch -p1 -d program

upload: getFiles
    diff $(DIFFFLAGS) .tmp/roboty program | (ssh $(user)@$(HOST) "umask 070 && patch -p1")

patch-extern:
    diff $(DIFFFLAGS) program program-workplace | patch -p1 -d program

patch-local:
    diff $(DIFFFLAGS) program program-workplace | patch -p1 -dR program-workplace

backup:
    tar cf backup.tar program-workplace

.ONESHELL:
clear:
    rm `find program-workplace/ -name "*~"`
    rm `find program-workplace/ -name "*.class"`
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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